Optional braces

Rainer Schuetze r.sagitario at gmx.de
Fri Aug 26 09:52:25 PDT 2011



On 26.08.2011 17:03, Andrei Alexandrescu wrote:
> On 8/25/11 9:13 PM, Walter Bright wrote:
>> But I worry that we might wind up tarting up the language with too many
>> a boatload of them, to the point where it becomes a confusing mass. At
>> what point should Meg Ryan stop with the plastic surgery? :-)
>
> It's a legitimate concern, and there's no right response to it. My point
> is that the argument is weak and caving to it would be a mistake. In
> essence Nick claims he can't be bothered to change:
>
> if (long_expression_one)
> if (long_expression_two)
> if (long_expression_three)
> statement
>
> with
>
> if ((long_expression_one)
> && (long_expression_two)
> && (long_expression_three))
> statement
>
> which adds a grand total of two parens.
>

I often write code like this:

if(auto p = getSome())
	if(auto parent = p.getParent())
		if(auto uncle = parent.getBrother())
			uncle.doSome();

This cannot be translated into a conjunction of conditions without 
having to specify declarators before. I would not like to lose that 
possiblity.

I'm not so sure about the dangling else issue. I don't want to be 
pampered all the time, but I have to admit to have run into that issue, too.


More information about the Digitalmars-d mailing list