Macro line continuation style?
Posted: Sat May 23, 2015 20:45
Not all of Minetest's code style is well-defined at this point. For 95% of matters we defer to the Linux kernel code style, since it seems to be somewhat of a standard among open source projects, is low friction, and tends to make a lot of sense. However, there is a problem with the Linux recommended macro line continuation style. The Linux style dictates a tab stop spacing of 8, and further, alignment indentation is done using tabs, so it always comes out consistent for Linux. For our own alignment indentation we override this, using spaces, like so:
However, if the tab size is set to 8 rather than 4, this same code would display as:
which is argued by some to be broken and ugly.
So, the proposed solution is to not align macro line continuation characters at all, using a single space instead:
I argue that, while this style may be more consistent, it is uglier and less readable than the broken version, and makes the code equally ugly when viewed under any tab stop spacing.
What do the rest of you think?
Here is the associated PR.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
#define FOOBAR(x) do { \
int __temp = (x); \
if (thing) \
some_stuff_here(&(x)); \
other(__temp); \
} while (0)
However, if the tab size is set to 8 rather than 4, this same code would display as:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
#define FOOBAR(x) do { \
int __temp = (x); \
if (thing) \
some_stuff_here(&(x)); \
other(__temp); \
} while (0)
which is argued by some to be broken and ugly.
So, the proposed solution is to not align macro line continuation characters at all, using a single space instead:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
#define FOOBAR(x) do { \
int __temp = (x); \
some_stuff_here(&(x)); \
other(__temp); \
} while (0)
I argue that, while this style may be more consistent, it is uglier and less readable than the broken version, and makes the code equally ugly when viewed under any tab stop spacing.
What do the rest of you think?
Here is the associated PR.