www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - multidimensional AAs

reply bobef <bobef_member pathlink.com> writes:
Are multidimensional AAs possible?

I have this:

byte[char[]][uint] m_on;

then when I say m_on["char"][13]=1;
dmd says that ot can't convert "char" to uint and 13 to char[]...
so I switch them and it compiles but it is supposed to work at all
and is this the way it should work?
(in my case I use variables of couse not "char" && 13)
May 11 2005
parent Burton Radons <burton-radons smocky.com> writes:
bobef wrote:

 Are multidimensional AAs possible?
 
 I have this:
 
 byte[char[]][uint] m_on;
 
 then when I say m_on["char"][13]=1;
 dmd says that ot can't convert "char" to uint and 13 to char[]...
 so I switch them and it compiles but it is supposed to work at all
 and is this the way it should work?
 (in my case I use variables of couse not "char" && 13)
Read declarations from right to left. That is an associative uint array of associative string arrays of bytes. So this would work instead: m_on[13]["char"]=1; This change was done some years back because the old declaration method was both right-to-left and left-to-right, leading to C's unreadable complex declarations, and particularly how confusing it was when you would break down a complex type into a series of typedefs. It's a thirty-year-old mistake (types should be on the right and read left-to-right) and we can't entirely fix it without breaking C declaration compatibility altogether.
May 11 2005