[phobos] Fwd: Re: Ruling out arbitrary cost copy construction?
Andrei Alexandrescu
andrei at erdani.com
Mon Nov 1 09:17:30 PDT 2010
On 11/1/10 10:59 AM, Michel Fortin wrote:
> Le 2010-11-01 à 0:21, Andrei Alexandrescu a écrit :
>
>> Alright, then how do we solve refcounting of constant objects (see
>> Michel Fortin's question)? My solution involves casting away const
>> and keeping immutability information at runtime. Is that
>> acceptable?
>
> I don't see a big problem in bypassing const. But const objects might
> be immutable, and immutable objects are implicitly shared. So for
> immutable objects you'll need to use atomic increment/decrement on
> the reference counter; is this why you want to keep track of
> immutability at runtime?
I keep immutability info during runtime to avoid trying to write to
immutable data.
I'm not sure about what to do for the GC affecting the reference count.
It does look like we need to use atomic refcounting, which is a major
setback for the entire approach.
In brief, if we want to go with cheap copy construction, we don't
currently have a solution.
Andrei
More information about the phobos
mailing list