Comments (7)
I'm not a great C coder, and I don't do much of the C in Fuzzball, but:
https://man.openbsd.org/style.9
https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9
These are the ones I check when I write code that I want to pass some sort of style guide.
from fuzzball.
Closing for lack of activity.
from fuzzball.
In this thread:
#329
I was mentioning the difference between indentation and alignment. Here's a nice example:
https://github.com/nyanster/fuzzball/pull/1/commits/fa3ea87e144af3e0e9c0ec89ac481e56e7eb209d
https://github.com/nyanster/fuzzball/pull/1
https://github.com/nyanster/fuzzball/blob/fa3ea87e144af3e0e9c0ec89ac481e56e7eb209d/include/dbsearch.h
Try putting it through expand(1). The comments always stay aligned. But the indentation can be moved as far left or right as a reader wants.
from fuzzball.
Okay. So, I'm gonna write up a style guide so there's something to argue over. It's the style of Unix code with a couple modern exceptions to improve readability. (it's BSD. If you find a System V style guide... you're free to offer it. But I don't think any exist) It's only for C, as I have no idea what'd be useful for MUF or MPI, and I don't feel a need for a style guide for stuff like sh or Tcl. (I write sh code in an easy-to-read way for me, and if it's not easy already, well, I plan to re-work some of the current scripts)
It follows:
Indent with tabs. Align with spaces. Tabs (indentation) have semantic meaning. Indentation is something that ONLY happens at the beginning of a line, and never in the middle of a line. Thus, your code should look the same no matter what tab size a reader uses, as it'll stay aligned no matter what. This also means there will never be mixed tabs and spaces.
Don't force things to fit in an 80x24 terminal. Use as many or as few columns as you need to. Use as many or as few lines as you need to. Make your code and comments readable.
Use C99. Assume the build environment fully supports C99. Don't worry about being compatible with C89 or with systems that don't have the standard library.
C and Unix have a close relationship. Keep this in mind when writing C code.
For anything not specified here, refer to these:
https://man.openbsd.org/style.9
https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9
Addendum: keep your commits and pull requests readable too! Be smart if you change style and code at the same time.
Unrelatedly (no this isn't part of the styleguide this is a new paragraph) we probably have too many ifdefs to easily use ctags
, at the moment.
@wyld-sw
@tanabi
Just tagging people~ I want your opinions!
For an explanation on indentation versus alignment:
https://dmitryfrank.com/articles/indent_with_tabs_align_with_spaces
http://www.lb-stuff.com/tabs
Both are good. The first one explains it better.
from fuzzball.
Indent with tabs. Align with spaces. Tabs (indentation) have semantic meaning. Indentation is something that ONLY happens at the beginning of a line, and never in the middle of a line. Thus, your code should look the same no matter what tab size a reader uses, as it'll stay aligned no matter what. This also means there will never be mixed tabs and spaces.
Looking back at this... Tabs are fine as separators when alignment is NOT desired. I've seen some examples of this in the code, where a single line of code is separated from a single comment by a tab, without relation to other code or comments.
from fuzzball.
I'll dig into this more when I've got a sec. I've got some counter proposals but haven't gotten around to assembling it.
from fuzzball.
As it's been… almost two years, eep, I should probably note that I'm no longer certain of the merits of auto-enforcing a coding style. Picking a coding style for consistency and aiming for it, yes, perhaps even setting up basic auto-format rules. However, it's likely not worth spending hours and hours getting an auto-formatter to handle every single edge case.
from fuzzball.
Related Issues (20)
- Use C++ Where Helpful
- Cleanup TODO's
- Fix Docker Issues HOT 3
- MUCK sudo command
- Small Request: "DONE" message after @dump HOT 5
- Appveyer Build Failure for Windows HOT 1
- Add allowing registration on login screen by @tune HOT 2
- Review and Document Listener Behaviour HOT 4
- {contents} MPI function does not behave as documented / nonsense exits behavior HOT 1
- READ from MUF called on Welcome Screen causes oddities HOT 1
- {force} allows escape character in input HOT 2
- Use XML to store helpfile content
- Make users always have a new dbref HOT 4
- Improve READ handling on Welcome Screen
- Appveyor build failing with Conan 2.0 HOT 1
- Wizards can GUEST themselves, but can't un-GUEST themselves HOT 3
- It Might Be Possible to Stack Overflow in propqueue(...) in timequeue.c HOT 1
- Idea: categorize messages (including in-server) with prefix coding HOT 3
- Propqueue Documentation Improvement HOT 2
- Oddities and server crash while MUF debugging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fuzzball.