Does D have "structural sharing" of immutable collections?

Chris Dew cmsdew at gmail.com
Wed May 23 07:50:46 PDT 2012


Thanks for your answer,

Chris.

On Wednesday, 23 May 2012 at 14:35:31 UTC, bearophile wrote:
> 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