Is DMD 0.166 RC 1.0?
Derek Parnell
derek at psyc.ward
Mon Sep 4 16:16:46 PDT 2006
On Mon, 04 Sep 2006 15:15:15 -0700, Walter Bright wrote:
> Derek Parnell wrote:
>>> It's an error in C++ for the same reason (can't initialize a reference
>>> with a non-const).
>>
>> You are right Walter. However, a[5] looks looks like an lvalue doesn't it?
>> In fact, it could have been one until the class author changed it to a
>> property. I feel that Properties need to behave as if they were data
>> members rather than methods when used as such. Thus ...
>>
>> f(a.prop);
>> and
>> f(a.prop());
>>
>> would look *and* behave differently but without surprising the coder.
>>
>> And this also means that
>>
>> a.prop++
>>
>> needs to work too. It is a great surprise to new comers that obvious things
>> like this are not working as expected.
>
> Whether it's consistent or not depends on how you think about it - what
> your mental model is of it. I'd rather have the odd cases produce error
> messages rather than have the compiler paper over what is likely a
> programmer oversight.
What 'odd case'?
What 'programmer oversight'?
The coder writes
a.prop++;
because the 'prop' is a data item in the object that she wants to
increment. It is irrelevant to the coder whether or not the class author
decided to implement this data item as a property or data member. From the
perspective of the user of the class, 'prop' represents some data in the
object. The implementation details are not a concern for the user of the
class.
--
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"
More information about the Digitalmars-d-announce
mailing list