Why isn't the array lenght property an lvalue?

Jeroen Bollen jbinero at gmail.com
Mon Apr 7 13:40:07 PDT 2014


On Monday, 7 April 2014 at 20:19:30 UTC, Justin Whear wrote:
> On Mon, 07 Apr 2014 20:14:13 +0000, Jeroen Bollen wrote:
>
>> On Monday, 7 April 2014 at 20:12:48 UTC, Justin Whear wrote:
>>> On Mon, 07 Apr 2014 19:13:30 +0000, Jeroen Bollen wrote:
>>>
>>>> When I have myarray.length, why isn't that considered an 
>>>> lvalue,
>>>> and as a result, why cannot I get a pointer to it?
>>>> 
>>>> It seems kinda dumb, I understand it cannot be changed 
>>>> manually,
>>>> but surely you should be able to get a const(type)* from it?
>>>
>>> I believe `length` is implemented as a property function,
>>> though I can't find the source for the life of me.
>> 
>> Then you still should be able to get a pointer of the result. 
>> I was also
>> considering it to be a @property function, as indeed that'd 
>> explain this
>> behaviour, but it still doesn't make sense to not allow it. 
>> After all,
>> length is just a variable.
>
> Unless the length function returns by ref, the result is an 
> rvalue and
> you won't be able to take a reference.
Why doesn't it return by reference? Seems kinda dumb.


More information about the Digitalmars-d mailing list