Persistent list

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 16 15:50:35 PST 2015


On Sunday, 15 November 2015 at 20:11:02 UTC, Dicebot wrote:
> On Sunday, 15 November 2015 at 19:51:09 UTC, Andrei 
> Alexandrescu wrote:
>> Just to clarify - is that referring to the part "We need to 
>> change that if we want things like composable containers that 
>> work with const." or to the "I think it's a good thing to 
>> want" part? -- Andrei
>
> Second part. I don't see a case for const containers at all. 
> Fully immutable functional style ones - sure, I have actually 
> experimented implementing cache this way in 
> https://github.com/Dicebot/mood/blob/master/source/mood/storage/generic_cache.d (thing that powers blog.dicebot.lv). But what would you use const containers for? Mixing mutable and immutable elements in one container? That sounds like a source of much trouble.

For the variance. If you wan't write in the container, you make 
make it so that

ConstContainer<B> implicitly convert to ConstContainer<A> if B 
inherit from A.

You can have code that accept mutable and const container as 
well, which is useful, because you can cram immutable container 
in the ro section.


More information about the Digitalmars-d mailing list