[:] as empty associative array literal, plus warning for null
Timon Gehr
timon.gehr at gmx.ch
Wed Jul 3 12:55:57 PDT 2013
On 07/03/2013 08:43 PM, TommiT wrote:
> On Wednesday, 3 July 2013 at 18:10:42 UTC, bearophile wrote:
>> TommiT:
>>> But I would expect [] to mean "empty dynamic array", not null. [..]
>> [..]
>>
>> This means you have to keep "null" in the language to represent an
>> empty associative array, because someone somewhere will surely want a
>> literal that avoids memory allocations. So lot of people will keep
>> using null, and the coding situation is improved about zero.
>
> Okay, I didn't realize an empty array would need to allocate.
Not necessarily if you allow the runtime to share the pointer for all
empty arrays.
More information about the Digitalmars-d
mailing list