optimized immutable containers

monarch_dodra monarchdodra at gmail.com
Wed Jul 3 22:45:35 PDT 2013


On Wednesday, 3 July 2013 at 22:03:14 UTC, w0rp wrote:
> On Wednesday, 3 July 2013 at 08:04:50 UTC, monarch_dodra wrote:
>> The irony here (as stated by Bearophile) is that this is 
>> currently how our SList and DList are actually implemented: 
>> Not value nor ref semantics: Just shared owner ship of nodes...
>
> Well, that was easy! I did not know that this is exactly how 
> SList and DList are implemented, as I haven't had to use them 
> yet, but that will come in handy eventualy.

Just to be clear, I didn't say it before: That behavior is a bug, 
and is currently undergoing correction. Please don't relly on it.

> The operations on the types could use more qualifiers, though. 
> Using them in pure functions would make it possible to 
> implicitly convert them to immutable, which is a powerful thing 
> indeed.

Keep in mind that in D, const is "turtles all the way down", so 
it is no possible to have an "immutable container of mutable 
items". Once you give something the "const" handle, it is very 
hard to strip it.


More information about the Digitalmars-d mailing list