This is the mail archive of the
mailing list for the GCC project.
Re: [patch] Compare addresses in operand_equal_p correctly
> On Tue, 14 Nov 2006, Andrew Haley wrote:
> > Insert extra parentheses so that Emacs will indent the code
> > properly. For example, the following indentation looks nice if you do
> > it by hand,
> > 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 Emacs would alter it. Adding a set of parentheses produces
> > something that looks equally nice, and which Emacs will preserve:
> > 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);
> I believe that this is to prevent *always* aligning equal operators
> under one another, when there's a good aesthetic reason, otherwise
> this ends up as:
> 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 is OK, but hides the utime/tv_sec/tv_usec symmetry.
> I'll agree that if you need to place operators of a multi-line
> conditional the same line, such as:
> return a->x == b->x && b->x == c->x
> && a->y == b->y && b->y == c->y
> && a->z == b->z && b->z == c-z;
> Then using parenthesis to avoid emacs auto-indent screwing things up.
> [But perhaps emacs has been fixed since then, I use vi :-)]
I prefer to insert parentheses around multiline return values, because
this causes the lines to be auto-indented properly with my current setup
of vim. I guess there might be some way how to get things auto-indented
properly even without them, though.