www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - why no .dup for associative arrays?

reply no where.com writes:
int main()
{
int[int] map, m2;

map[0]++;

m2 = map.dup;

return 0;
}

map.d:7: no property 'dup' for type 'int[int]'

What's the reason for this, why associative array is different from other
objects?
Dec 12 2004
next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
no where.com wrote:

 map.d:7: no property 'dup' for type 'int[int]'
 
 What's the reason for this, why associative array
 is different from other objects?

There is no static init for AA either, I think (guess) one reason is that the internal format is not fixed ? So it's probably a "bug". Probably known, but anyway. --anders
Dec 12 2004
prev sibling parent "Walter" <newshound digitalmars.com> writes:
<no where.com> wrote in message news:cpi6p0$2lik$1 digitaldaemon.com...
 int main()
 {
 int[int] map, m2;

 map[0]++;

 m2 = map.dup;

 return 0;
 }

 map.d:7: no property 'dup' for type 'int[int]'

 What's the reason for this, why associative array is different from other
 objects?

Essentially because it never occurred to me :-( The .dup would come in handy for some kinds of lock-free data structures.
Dec 12 2004