Phobos2: iota, ranges, foreach and more

Nick Sabalausky a at a.a
Mon May 4 18:54:57 PDT 2009


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:gto3np$2blr$1 at digitalmars.com...
> Georg Wrede wrote:
>> bearophile wrote:
>>>
>>> While reading the source code of Phobos2 function calls like ".front"
>>> confuse me, I find ".front()" more readable. I think I am not the
>>> only one to think like this.
>>
>>
>> The docs should be consistent and clear, also in trivial matters. If 
>> something is a function, then the parens should be there. The reader may 
>> know that you can omit the parens, but it has to be easy for him to 
>> recognize a name as a function.
>
> Omitting parens gives more options. For example, infinite ranges are 
> defined and recognized as:
>
>     enum bool empty = false;
>
>

See, this is a good reason why "()" vs "no ()" should be dictated by the 
API, not the caller. Under the current system, there's nothing preventing 
someone from writing an "is this range empty?" check that seems to work on 
one range, but then fails to compile on any range that chooses to implement 
"empty" as in your example above. 





More information about the Digitalmars-d mailing list