Persistent list

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 14 12:55:21 PST 2015


On 11/14/2015 12:10 AM, Andrei Alexandrescu wrote:
> ...
> * Lines 11-12: I came to terms with the notion that some types cannot be
> made immutable. We've been trying to do reference counting on immutable
> objects for a long time. It's time to acknowledge that true immutability
> (which the immutable keyword models) and reference counting don't mix.
> Const does work (more below). But overall I'm at peace with the notion
> that if you can't live without immutable, I'll refer you to the garbage
> collector.
> ...

I.e. you think it is fine that there can be no list of lists.
Anyway, the static assert does not actually do what you intend it to do.

> * Lines 26-29: The allocator is fundamentally a mutable part of the
> container. This is an insufficiency of our type system - we can't say
> "this object may be constant, but this reference is to a mutable part of
> it". We can't explain that necessity out of existence, and List is part
> of the proof. So we need to make that cast legal.
> ...

Just don't make the method const. (This is not C++.)



More information about the Digitalmars-d mailing list