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
I need some immutable collections for my D Compiler Tools
project, namely linked list, red-black tree, and possibly some
others.
So I'm going to create them for my use, and later generalize.
I've created a project on GitHub, but didn't implement anything
useful yet.
Some more information is available at
http://d-coding.com/2012/05/21/functional-data-structures.html