Re: Nested associative arrays

2010-11-14 Thread Jacob Carlborg
o had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to handle nested associative arrays ? Well, yes. The following code: module main; void main () { auto tree = ["" : ["" : ""]]; } Using DMD 1.06

Re: Nested associative arrays

2010-11-14 Thread spir
On Sun, 14 Nov 2010 10:35:42 +0100 spir wrote: > > 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. > > ... w

Re: Nested associative arrays

2010-11-14 Thread spir
On Sun, 14 Nov 2010 00:03:48 + div0 wrote: > yeah, but dmd's parser was written by hand so it's not surprising there > are inconsistency's with what works where. Well, most (all?) truely used languages have hand-written parsers, AFAIK. The issue is not with writing the parser, I guess, bu

Re: Nested associative arrays

2010-11-13 Thread div0
On 14/11/2010 00:28, Ellery Newcomer wrote: On 11/13/2010 02:02 PM, spir wrote: On Sat, 13 Nov 2010 17:27:08 + But the compiler (D2) accepts nested aa literals remaining anonymous: writeln(["a" : ["b" : "c"]]); // --> "a:b:c" (where "auto aa = ..." fails) The difference is initializer

Re: Nested associative arrays

2010-11-13 Thread Ellery Newcomer
On 11/13/2010 02:02 PM, spir wrote: On Sat, 13 Nov 2010 17:27:08 + But the compiler (D2) accepts nested aa literals remaining anonymous: writeln(["a" : ["b" : "c"]]);// --> "a:b:c" (where "auto aa = ..." fails) The difference is initializer vs expression. initializers occu

Re: Nested associative arrays

2010-11-13 Thread bearophile
div0: > 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. One of my many enhancement requests, no one disturbs their sleep

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 20:02, spir wrote: On Sat, 13 Nov 2010 17:27:08 + div0 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 instea

Re: Nested associative arrays

2010-11-13 Thread spir
On Sat, 13 Nov 2010 17:27:08 + div0 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 "" > > Whe

Re: Nested associative arrays

2010-11-13 Thread div0
them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to handle nested associative arrays ? Well, yes. The following code: module main; void main () { auto tree = ["" : ["" : ""]]; } Using DMD 1.065 results in: Assertion failed: (0),

Re: Nested associative arrays

2010-11-13 Thread Ellery Newcomer
Wow. Yeah, I guess all bets are off when it comes to initializations. In the meantime, I guess you'll have to use string[string][string] tree; tree = ["" : ["" : ""]]; On 11/13/2010 05:02 AM, Jacob Carlborg wrote: Well, yes. The following code: module main; void main () { auto tree = ["" :

Re: Nested associative arrays

2010-11-13 Thread Jacob Carlborg
On 2010-11-13 14:39, bearophile wrote: Jacob Carlborg: module main; void main () { auto tree = ["" : ["" : ""]]; } Using DMD 1.065 results in: Assertion failed: (0), function toExpression, file init.c, line 437. Please put it in Bugzilla if not already present :-) Bye, bearophile

Re: Nested associative arrays

2010-11-13 Thread Jacob Carlborg
lborg wrote: Is D supposed to be able to handle nested associative arrays ? Well, yes. The following code: module main; void main () { auto tree = ["" : ["" : ""]]; } Using DMD 1.065 results in: Assertion failed: (0), function toExpression, file init.c, line 437.

Re: Nested associative arrays

2010-11-13 Thread div0
le to handle nested associative arrays ? Well, yes. The following code: module main; void main () { auto tree = ["" : ["" : ""]]; } Using DMD 1.065 results in: Assertion failed: (0), function toExpression, file init.c, line 437. That's static initialisati

Re: Nested associative arrays

2010-11-13 Thread bearophile
Jacob Carlborg: > module main; > > void main () > { > auto tree = ["" : ["" : ""]]; > } > > Using DMD 1.065 results in: > > Assertion failed: (0), function toExpression, file init.c, line 437. Please put it in Bugzilla if not already present :-) Bye, bearophile

Re: Nested associative arrays

2010-11-13 Thread Jacob Carlborg
On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to handle nested associative arrays ?

Re: Nested associative arrays

2010-11-12 Thread Ellery Newcomer
Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to handle nested associative arrays ?

Nested associative arrays

2010-11-12 Thread Jacob Carlborg
Is D supposed to be able to handle nested associative arrays ? -- /Jacob Carlborg