On Jan 30, 2018, Richard Sandiford <[email protected]> wrote:
>> But it is my understanding that both of the following are correct:
>>
>> return (verylongcondition____________________________________
>> && otherlongcondition__________________________________);
>>
>> return verylongcondition____________________________________
>> && otherlongcondition__________________________________;
>>
>> The first, because the parenthesized expression is continued with
>> indentation to match the parenthesis, the second because the return
>> statement is continued with the correct indentation for the continuation
>> of a statement.
> Thought it had to be the first. When they talk about indenting leading
> operators, the conventions say:
> Insert extra parentheses so that Emacs will indent the code properly.
> which at least implies that not inserting parantheses and indenting by
> two spaces isn't "properly".
Hmm, in my reading, the "properly" there was to contrast with the IMHO
improper, excessive manual indentation in the example that follows it:
v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
+ rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
but I think it's just as legitimate to instead understand that the above
indentation is proper, and that the only problem with it is that
mechanical reindent would turn it into
v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
+ rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
which, in *this* case, would be wrong, because you'd have '=' and '+'
operators, of different precedence, at the same level of indentation.
But in the case of return, there's no such issue with operator
precedence.
I'll raise this issue at [email protected] and request
clarification.
> And I think most GCC code does stick to that (i.e. use the bracketed form).
Let's see what GNU decides, then we can decide whether to add a
GCC-specific constraint, if GNU doesn't impose it already.
Thanks!
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer