@disable
Clemens
eriatarka84 at gmail.com
Fri Jan 15 01:40:19 PST 2010
Andrei Alexandrescu Wrote:
> Clemens wrote:
> > Andrei Alexandrescu Wrote:
> >
> >> The main idea is to allow creation of noncopyable types by marking
> >> this(this) as @disable.
> >
> > I must be missing something, but isn't this usually done by making the copy constructor private?
>
> Well one issue is that in D private has module granularity, which means
> that inside a given module you could still create objects. That has the
> advantage of obviating the need for "friend", but disables the private
> constructor idiom.
>
> Andrei
I thought about that, but it seemed to me that the D philosophy is that modules can be trusted to "do the right thing" internally. Then again, I can see how, due to its implicit nature, invoking a copy constructor "accidentally" may be easier than invoking a private method, leading to subtle bugs.
More information about the Digitalmars-d
mailing list