Kinds of containers

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 24 12:19:14 PDT 2015


On 10/24/2015 11:22 AM, Jacob Carlborg wrote:
> On 2015-10-21 13:05, Andrei Alexandrescu wrote:
>
>> 1. Functional containers.
>>
>> These are immutable; once created, neither their topology nor their
>> elements may be observably changed. Manipulating a container entails
>> creating an entire new container, often based on an existing container
>> (e.g. append takes a container and an element and creates a whole new
>> container).
>>
>> Internally, functional containers take advantage of common substructure
>> and immutability to share actual data. The classic resource for defining
>> and implementing functional containers is
>> http://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504.
>>
>
> Can these be implemented by the user just declaring a regular container
> as immutable? The implement will recognize if it's declared as immutable
> and adapt.
>

Even if this was possible, it would not be a very good idea. Persistent 
data structures have use cases that would be hindered by required 
transitive immutability.


More information about the Digitalmars-d mailing list