Persistent list

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 15 16:00:17 PST 2015


On 11/15/2015 04:45 PM, Dicebot wrote:
> On Sunday, 15 November 2015 at 21:00:40 UTC, Andrei Alexandrescu wrote:
>> On 11/15/2015 03:11 PM, Dicebot wrote:
>>> 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?
>>
>> Passing arguments to functions that aren't supposed to change the
>> containers. -- Andrei
>
> For that you don't need to mutate neither allocator nor RC (unless that
> const argument is actually leaked from inside the function to somewhere
> else - terrible, terrible thing to do). So strict physical const should
> suffice.

This illustrates a simple procedural problem. The entire point of my 
posting a simple example of a complete container was to avoid 
hypotheticals such as this. The code is there and shows that no, 
physical const does not suffice. At least I don't know how to do it. If 
you think it does there's one way to show it, it's easy - write the code 
that does it.

We could sit on our testes all day long, speculate how things ought to 
work, and feel awfully smart in the process. It's very easy to do. Hell, 
I've done it more than too many times. What's more difficult is have a 
positive, constructive approach that builds on a weak solution to 
improve it. This is the kind of dialog we need to foster.


Andrei



More information about the Digitalmars-d mailing list