D newb
bearophile
bearophileHUGS at lycos.com
Sun Aug 17 17:39:55 PDT 2008
Robert Fraser:
> scope Foo f = new Foo();
>
> The "scope" keyword in the declaration says to the compiler "this will
> not escape the function" thus creating the data on the stack. "f" is
> still a reference type in this case, however (although it may not be
> implemented as a reference -- that's up o the compiler).
But the 'scope' works only in some situations, the original poster can take a look at the docs about 'scope'.
My question: does the compiler raise a compilation error if the 'scope' keyword is used where the compiler can't actually allocate the class on the stack? (if not, then I think it may be better for the compiler to raise such error, avoiding the illusion of efficiency).
Bye,
bearophile
More information about the Digitalmars-d
mailing list