Nested associative arrays

div0 div0 at sourceforge.net
Sat Nov 13 16:03:48 PST 2010


On 13/11/2010 20:02, spir wrote:
> On Sat, 13 Nov 2010 17:27:08 +0000
> div0<div0 at sourceforge.net>  wrote:
>
>>> How about "associative array literal" then? Regardless of what you call
>>> it I shouldn't get an assertion failure.
>>>
>>
>> True. It's been fixed in dmd2 though, you get:
>>
>> Error: Integer constant expression expected instead of ""
>>
>> When it's auto the compiler thinks you are doing static initialisation
>> of a flat array, not an AA. You have to do what Ellery said.
>
> But the compiler (D2) accepts nested aa literals remaining anonymous:
>      writeln(["a" : ["b" : "c"]]);	// -->  "a:b:c"
> (where "auto aa = ..." fails)
>
> Denis
> -- -- -- -- -- -- --
> vit esse estrany ☣
>
> spir.wikidot.com
>

yeah, but dmd's parser was written by hand so it's not surprising there 
are inconsistency's with what works where.

I finally found the bit where it describes associative array literals 
and they look identical to initialising a flat array, so god only knows 
which one gets picked when. It would be better if they where made different.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


More information about the Digitalmars-d-learn mailing list