Kinds of containers

Ulrich Küttler via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 26 15:05:01 PDT 2015


On Monday, 26 October 2015 at 20:46:21 UTC, Timon Gehr wrote:
> On 10/26/2015 08:31 PM, Ulrich Küttler wrote:
>> On Wednesday, 21 October 2015 at 18:49:26 UTC, Andrei 
>> Alexandrescu wrote:
>>> On 10/21/2015 12:25 PM, Jonathan M Davis wrote:
>>>> My experience with immutable containers is that their 
>>>> performance is
>>>> trash precisely because you can't mutate them.
>>>
>>> That's actually the experience in the Scala community. Over 
>>> and again
>>> people start with immutable containers all over the place 
>>> because
>>> they're cool, and end up with mutable containers because they 
>>> work. --
>>> Andrei
>>
>> Ranges and loops. Same story. Ranges are cool, loops get stuff 
>> done.
>>
>
> This kind of reasoning sounds cool but is ultimately misguided.
> (I don't think the stories are even analogous.)
>

Nobody argues against ranges.

The argument is: Designing range-based code results in something 
very different from traditional loop-based code. There are very 
good reasons why the effort is worthwhile, still, the effort is 
real. (See the calendar example.) Even those library primitives 
do not come for free.

The same is true about containers. The container variant is a 
design choice, not an implementation detail. Now, are persistent 
containers worth the effort? What would a design based on 
persistent containers look like? Is there a good way to implement 
them in D?

Who knows.



More information about the Digitalmars-d mailing list