emplace, scope, enforce [Was: Re: Manual...]
bearophile
bearophileHUGS at lycos.com
Wed Jul 21 05:26:25 PDT 2010
Dmitry Olshansky:
> The problem is designing such classes and then documenting: "you should
> always use it as 'scope' ", is awkward.
If you really want a class to be used as scope only you can do this, see the error message:
scope class Foo {}
void main() {
Foo f = new Foo;
}
> The second writefln prints garbage. I guess it's because of pointer to
> the long gone stackframe, which is ovewritten by the first writeln.
Yes scope has this and other problems (and I think two of them can be fixed), but I don't think emplace() is a big improvement.
Bye,
bearophile
More information about the Digitalmars-d
mailing list