Does D have "structural sharing" of immutable collections?

bearophile bearophileHUGS at lycos.com
Wed May 23 07:35:30 PDT 2012


Chris Dew:

> Does D have "structural sharing" of its immutable collections?
>
> i.e. Can I make a copy of an immutable Map or List collection 
> with an extra (or mutated) member, and will the returned (new) 
> collection share most of it's structure with the earlier 
> collection.

Currently Phobos doesn't have a Map (there are built-in 
associative arrays), and there isn't a true List (there is a 
linked list, that so far I have not used).
Currently I think nothing in D works as you ask, it doesn't even 
have "immutable collections" like a Finger Tree or something.
But writing such collections is well within D type system 
capabilities, so I think eventually they will be present in 
Phobos if there is enough need.

Bye,
bearophile


More information about the Digitalmars-d mailing list