Re: use variant as associative array

2010-02-13 Thread GG
We can't assign value to Variant associative array because there is a bug, I found this : http://d.puremagic.com/issues/show_bug.cgi?id=2451 So the issue is already assigned...I'm waiting. Yes there is a .length for associative array and now aa.length works with the last fix : http://d.puremagic

Re: use variant as associative array

2010-02-11 Thread GG
I tried std.boxer, Box[char[]][int] bb; bb[0]["Month"] = box("Jan"); bb[0]["Profit"] = box(800); bb[1]["Month"] = box("Jan"); bb[1]["Profit"] = box(200); /*section work*/ writefln("%s",bb[0]["Month"]); writefln("%d",bb[0]["Pro

Re: use variant as associative array

2010-02-11 Thread Daniel Keep
GG wrote: > Yes I can't use struct and/or enum because I can't know type and number of > data that user could pass. > In this example, we talk about Month, but it could be Minutes, week... So I > try to program dynamic not static. If you're trying to program dynamically, then you're using the

Re: use variant as associative array

2010-02-11 Thread GG
Yes I can't use struct and/or enum because I can't know type and number of data that user could pass. In this example, we talk about Month, but it could be Minutes, week... So I try to program dynamic not static. In fact I'm learning D thought a little project of graphic chart. I would like to

Re: use variant as associative array

2010-02-11 Thread Daniel Keep
Daniel Keep wrote: > I got the following to work with Tango's Variant (dmd 1.051 + pre-0.99.9 > trunk): > > Variant[char[]][int] aa; > > aa[0] = typeof(aa[0]).init; > aa[0]["Month"] = Variant("Jan"); > aa[0]["Profit"] = Variant(500); > > aa[1] = typeof(aa[0]).init; > aa

Re: use variant as associative array

2010-02-11 Thread Daniel Keep
GG wrote: > I try to use variant as associative array with dmd2.039, > > Variant[char[]][int] aa; > aa[0]["Month"] = "Jan"; > aa[0]["Profit"] = 500; > aa[1]["Month"] = "Feb"; > aa[1]["Profit"] = 800; > > I g

Re: use variant as associative array

2010-02-11 Thread downs
On 10.02.2010 22:28, GG wrote: > I try to use variant as associative array with dmd2.039, > > Variant[char[]][int] aa; > aa[0]["Month"] = "Jan"; > aa[0]["Profit"] = 500; > aa[1]["Month"] = "Feb"; > aa[1]["Profit"]

Re: use variant as associative array

2010-02-11 Thread Philippe Sigaud
On Thu, Feb 11, 2010 at 21:22, GG wrote: > I tried your trick but I got "Error: cannot append type string to type > VariantN!(maxSize)[]" > on : vars ~= "Jan"; > > I found this : http://d.puremagic.com/issues/show_bug.cgi?id=3692, the > issue has been REOPEN. > > Thanks for helping ! > Hmm, it

Re: use variant as associative array

2010-02-11 Thread GG
Sorry, but I ckicked on REPLY and it created a new thread after posting!?

Re: use variant as associative array

2010-02-11 Thread GG
I tried your trick but I got "Error: cannot append type string to type VariantN!(maxSize)[]" on : vars ~= "Jan"; I found this : http://d.puremagic.com/issues/show_bug.cgi?id=3692, the issue has been REOPEN. Thanks for helping !

Re: use variant as associative array

2010-02-11 Thread Philippe Sigaud
On Wed, Feb 10, 2010 at 22:28, GG wrote: > I try to use variant as associative array with dmd2.039, > > I got core.exception.rangeer...@main(28): Range violation > I had the same problem a few months ago. It's the same with Algebraic, too bad. alias TypeTuple!(int, str

use variant as associative array

2010-02-10 Thread GG
I try to use variant as associative array with dmd2.039, Variant[char[]][int] aa; aa[0]["Month"] = "Jan"; aa[0]["Profit"] = 500; aa[1]["Month"] = "Feb"; aa[1]["Profit"] = 800; I got core.exception.rangeer...@main(28): Range violatio