2013/2/9 kenji hara <[email protected]>

> 2013/2/9 Jonathan M Davis <[email protected]>
>
>> And I _definitely_ wouldn't want to set a precedence for front to be
>>
> declared as a non-property function. It needs to be consistently called
>> without parens to work in generic code, and if arrays are able to use
>> front
>> with parens, then we definitely risk a lot of range-based functions being
>> written incorrectly due to the fact that far too often, range-based
>> functions
>> only end up being tested with arrays, and in that case, the parens
>> wouldn't
>> cause an error like they should. It wouldn't be caught until someone
>> actually
>> tried it with another type of range (possibly much later). Granted, the
>> writer
>> of the range-based function should have tested it better, but given that
>> arrays are by far the most common type of range, I think that it's just
>> asking
>> for trouble to allow their front or back to be used with parens.
>>
>
> Sorry I cannot imagine an actual use case you are considering.
>

Ah... do you consider this case?

import std.array : front;
int delegate()[] eventHandlers;
auto result = eventHandlers.front(); // want to _call_ eventHandlers[0]

Indeed, under the my proposal, typeof(result) becomes `int delegate()`, not
`int`.

Hmmmm.....

Kenji Hara

Reply via email to