optimized immutable containers
w0rp
devw0rp at gmail.com
Wed Jul 3 23:36:43 PDT 2013
On Thursday, 4 July 2013 at 05:45:41 UTC, monarch_dodra wrote:
> 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.
I see. Well, a garbage collected linked list is very easy to
implement, so I suppose it's easy for you to get these semantics
if you want them.
>> 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 not possible to have an "immutable container of mutable
> items". Once you give something the "const" handle, it is very
> hard to strip it.
I am aware of how const and immutable work, and that's what I
want. It's just nice that with a pure qualifier, you can
sometimes build immutable data from functions returning mutable
data without creating any copies.
More information about the Digitalmars-d
mailing list