Omittable parens is an evil

Robert Fraser fraserofthenight at gmail.com
Sat Jul 19 19:49:45 PDT 2008


Nick Sabalausky wrote:
> "Manfred_Nowak" <svv1999 at hotmail.com> wrote in message 
> news:g5tmqq$b99$2 at digitalmars.com...
>> Mike wrote:
>>
>>> "this does something" (parens) and "this is data" (no parens)
>> Compare this with this extract of your other posting:
>>>  opAddAssign(auto value) { _bar += value; }
>>>                // it's extremely extendable!
>> Yes it is extremely extentable because one can incorporate calls to
>> some arbitrary functions into the body of `opAddAssign':
>>
>>   opAddAssign(auto value) {
>>     _bar += value;
>>     action();
>>     procedure();
>>   }
>>
>> ... bang!!! Your "clear _VISUAL_ distinction" has been lost.
>>
>> -manfred
>>
> 
> When looking at code that accesses a property or uses an operator that is 
> overloadable, you don't usually need to know if extra processing is going on 
> behind-the-scenes (typically only when optimizing). But when looking at code 
> that involves a function, the distrinction between "invoked"/"not invoked" 
> is almost always (if not always) a very important make-or-break matter.

I agree. A property getter should be idempotent (cached values aside). 
That cannot be assumed about all parameter-less functions.



More information about the Digitalmars-d mailing list