structs and opAssign -- why not?

Reiner Pope reiner.pope at gmail.REMOVE.com
Mon Nov 20 00:00:15 PST 2006


== Quote from Stewart Gordon (smjg_1998 at yahoo.com)'s article
> Bill Baxter wrote:
> <snip>
> > Basically "it bugs me, and there's no compelling use case".
> > I think RAII is a compelling use case.  Expression templates are another
> > thing that has been talked about.
> >
> > At the very least I think D needs to have some sort of reasonable
> > solution for smart pointers.  Fleshing out structs seems one reasonable
> > way to go about it.
> <snip>
> To bypass the restriction that scope object references cannot be
> changed?  If we're going to add something to the language for this, why
> not just remove the restriction?
> Stewart.
Reference counting is the only safe way to remove the restrictions on auto types
(because, if you have a way to specify stack variables, then you get many more
dangling pointer problems, which GC was introduced to avoid in the first place).
Unless RC will be implemented in the language, then allowing opAssign and smart
pointers is a good way to help people manage resources.

Bill mentioned another use of opAssign: expression templates. These have nothing
to do with scoped variables.

Cheers,

Reiner



More information about the Digitalmars-d mailing list