[phobos] Fwd: Re: Ruling out arbitrary cost copy construction?
Andrei Alexandrescu
andrei at erdani.com
Mon Nov 1 11:39:57 PDT 2010
On 11/1/10 10:22 AM, Masahiro Nakagawa wrote:
> On Mon, 01 Nov 2010 13:21:23 +0900, Andrei Alexandrescu
> <andrei at erdani.com> wrote:
>
>> 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?
>
> Your approach seems to be C++'s mutable. I am acceptable.
>
> You said "There are several solutions possible" on digitalmars.D.
> Can you show the example of other solutions?
One other solution is to simply say
@refcounted struct Widget { ... }
and let the compiler take care of everything.
> "the compiler knowing about the idiom" means Python-like approach?
> If so, I think such approach makes the compiler more complex :(
I agree.
Andrei
More information about the phobos
mailing list