Getter an lvalue and cannot be modified

IntegratedDimensions IntegratedDimensions at gmail.com
Sun May 27 23:21:05 UTC 2018


On Sunday, 27 May 2018 at 09:28:36 UTC, Mike Franklin wrote:
> On Sunday, 27 May 2018 at 09:23:09 UTC, IntegratedDimensions 
> wrote:
>> C[] c;
>> @property C[] get() { return c; }
>>
>> get ~= something;
>>
>> errors out, yet
>>
>> auto q = get;
>> q ~= something;
>>
>> is fine.
>>
>>
>> Why is D thinking that ~= is being applied to get, the 
>> function, rather than what it returns?
>>
>> Also
>>
>> When I converted a field in to a property, an AA, it is 
>> returning null rather than being initialized by default. Seems 
>> like properties are broke. I'd expect a property getter to 
>> behave, for all intents and purposes as if it were field. I 
>> shouldn't have to have a temp variable to be able to use it as 
>> such.
>
> You'll probably get your answer and more by reading this:  
> https://github.com/dlang/DIPs/pull/97
>

I came across a few posts mentioning this after the fact. It's 
been this way since at least 2012 so... It's now may so not sure 
how much longer we'll have to wait. That pull seems to have 
stalled. So close but so far away ;/





More information about the Digitalmars-d-learn mailing list