bigfloat

bearophile bearophileHUGS at lycos.com
Wed Apr 8 16:40:56 PDT 2009


Andrei Alexandrescu:
> Great point. My hope is that one day I'll manage to convince Walter and 
> Sean to simply replace V[K] types with AssocArray!(K, V) and then make 
> AssocArray a regular template inside object.d. The current 
> implementation of associative arrays looks... brutal.

Maybe some compromise can be found. I think the current syntax is good enough.

A possible idea is to translate the current AA code to D and create a D module (that object imports, if you want) that contains something like that AssocArray!(K, V).
Some very useful things are missing in the current AAs:
- OpEquals among AAs, very useful in unit tests, to assert that functions return a correct AA.
- Empty AA literal (or expression, I currently use AA!(T, S)).
- Empty AAs can be false.
- A way to clear an AA, like aa.clear or aa.clear();
- A way to perform a shallow copy, like aa.dup
- Possibly lazy view of keys, values and key-value pairs, as in Java and Python3.
- A more precise management by the GC.

Then the compiler can map the current syntax to the AssocArray!(K, V) template struct/class and its functionality. I don't know if this can be done.
It's also a way to reduce the C code and translate some of it to D.

Bye,
bearophile



More information about the Digitalmars-d mailing list