Re: C99: Suggestions for style(9)



In message: <49FADEF3.5010106@xxxxxx>
Christoph Mallon <christoph.mallon@xxxxxx> writes:
: Marius Strobl schrieb:
: > On Sun, Apr 26, 2009 at 09:02:36AM +0200, Christoph Mallon wrote:
: >> return with parentheses:
: >> Removed, because it does not improve maintainability in any way. There
: >> is no source for confusion here, so the rule even contradicts the rule,
: >> which states not to use redundant parentheses. Maybe, decades ago it was
: >> just a workaround for a broken compiler, which does not exist anymore.
: >
: > FYI, the idea behind this rule is said to be to able to use
: > a macro return(), f.e. for debugging you then can do:
: > #define return(x) do { \
: > printf("returning from %s with %d\n", __func__, (x)); \
: > return (x); \
: > } while (0)
: >
: > Given the this is a nifty feature and parentheses around the
: > return value don't hurt maintainability in any way IMO this
: > rule should stay.
:
: This is mentioned nowhere in style(9) (in general it is lacking reasons
: why something is some way or the other).

It has been an example used for the past 15 years at least as to why
to do this... I don't know how many people have actually used the
ability to do this in code.

: Also I consider this as gross abuse: Macro names shall be in all
: uppercase, so it is clear that there is a macro at work. Therefore
: "return" is not a candidate. So this would violate yet another rule in
: style(9) (the original return already violates the no-redundant
: parentheses rule).
: Also I would not mention __func__: there were objections against using
: it in the past (though I, logically, prefer its use).

It is a debugging aid, but one of dubious value for a far more
fundamental reason:

return;

will break any macro.

Warner
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: C99: Suggestions for style(9)
    ... because it does not improve maintainability in any way. ... There is no source for confusion here, so the rule even contradicts the rule, which states not to use redundant parentheses. ... so it is clear that there is a macro at work. ... the parentheses are not redundant) would be for local debugging ...
    (freebsd-hackers)
  • Re: C99: Suggestions for style(9)
    ... because it does not improve maintainability in any way. ... There is no source for confusion here, so the rule even contradicts the rule, which states not to use redundant parentheses. ... Also I consider this as gross abuse: Macro names shall be in all uppercase, so it is clear that there is a macro at work. ... So this would violate yet another rule in style. ...
    (freebsd-hackers)
  • Re: C99: Suggestions for style(9)
    ... because it does not improve maintainability in any way. ... Given the this is a nifty feature and parentheses around the ... so it is clear that there is a macro at work. ... the parentheses are not redundant) would be for local debugging ...
    (freebsd-hackers)
  • Re: C99: Suggestions for style(9)
    ... because it does not improve maintainability in any way. ... which states not to use redundant parentheses. ... a macro return, f.e. ... Given the this is a nifty feature and parentheses around the ...
    (freebsd-hackers)