Partial modification of DIP23 to allow module level property

kenji hara k.hara.pg at gmail.com
Fri Feb 8 22:26:10 PST 2013


2013/2/9 kenji hara <k.hara.pg at gmail.com>

> 2013/2/9 Jonathan M Davis <jmdavisProg at gmx.com>
>
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130209/96945462/attachment-0001.html>


More information about the Digitalmars-d mailing list