Kinds of containers

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 21 11:55:10 PDT 2015


On 10/21/2015 01:42 PM, Ulrich Kuettler wrote:
> On Wednesday, 21 October 2015 at 11:05:12 UTC, Andrei Alexandrescu wrote:
>> I'm finally getting the cycles to get to thinking about Design by
>> Introspection containers. First off, there are several general
>> categories of containers. I think D should support all properly. One
>> question is which we go for in the standard library.
>>
>> 1. Functional containers.
>
> Very much in favor of functional (or persistent) containers. Immutable.
> Value semantics.
>
> This might take some getting used to, but if properly designed these
> containers would be killer for D. A dream come true.

I agree they're cool.

>> 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.
>>
>>
>
> An insanely beautiful example is clojure's PersistantVector. AFAIK it
> made its way into Scala, too.

Far as I understand from 
http://hypirion.com/musings/understanding-persistent-vector-pt-1, it's 
that tree thing with carefully chosen slot sizes for cache friendliness?


Andrei



More information about the Digitalmars-d mailing list