Taking address of properties

FG home at fgda.pl
Fri Feb 8 13:15:28 PST 2013


On 2013-02-08 21:13, Steven Schveighoffer wrote:
>> I can't find anything about that front has to be a property here:
>> http://dlang.org/phobos/std_range.html#isInputRange
>>
>> all it states that you can get the current element by issuing:
>>     r.front
>> which would still be possible with the optional parentheses of DIP23.
>
> Technically this is true.  But the expectation is that r.front is a
> property/field, not a function.  That aspect is difficult to capture in a
> template, especially in the current implementation where @property on a getter
> is essentially redundant info.


There may be nothing saying that r.front has to be a @property, but don't forget 
setters. There are many examples of the following statement:

     r.front = val;

Just look at the sources: grep -R "\.front = " ./src/phobos/
General agreement is that plain functions shouldn't be allowed to be called
like setters, with assignment operator. So what now? Should all that code be
changed to use r.front(val) instead? Or should void front(T val) remain a
@property, while ref T front() becomes a plain function?



More information about the Digitalmars-d mailing list