Why isn't the array lenght property an lvalue?

Iain Buclaw ibuclaw at gdcproject.org
Tue Apr 8 11:00:17 PDT 2014


On 7 April 2014 22:18, MrSmith <mrsmith33 at yandex.ru> wrote:
> On Monday, 7 April 2014 at 20:43:09 UTC, Steven Schveighoffer wrote:
>
>> On Mon, 07 Apr 2014 16:30:13 -0400, MrSmith <mrsmith33 at yandex.ru> wrote:
>>
>>> On Monday, 7 April 2014 at 19:58:21 UTC, Jeroen Bollen wrote:
>>>>
>>>> On Monday, 7 April 2014 at 19:56:38 UTC, MrSmith wrote:
>>>>>
>>>>> On Monday, 7 April 2014 at 19:23:45 UTC, Jeroen Bollen wrote:
>>>>>>
>>>>>> On Monday, 7 April 2014 at 19:13:31 UTC, 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?
>>>>>>
>>>>>>
>>>>>> Well type would be ulong, so const(ulong)*
>>>>>
>>>>>
>>>>> Array length is size_t which is uint on x86 and ulong on x86_64.
>>>>
>>>>
>>>> Alright, but why can't you get a pointer to it?
>>>
>>>
>>> I've tried, but no luck here
>>> http://dpaste.dzfl.pl/be526902ef4f
>>
>>
>
> Cool! So, it is not a property function but actual size_t? How would it grow
> then?

The compiler detects the pattern and invokes a runtime call to set the
new array length.  If the new size is greater than the current
allocated pool for the array, then it's realloc'd on the GC.


More information about the Digitalmars-d mailing list