Does scope not work on parameters?
Russ
russpowers at gmail.com
Sun Feb 23 03:01:43 UTC 2020
Hi, I've been playing around with having classes allocated on the
stack. I am using the scope keyword for local variables. I
assumed that the scope modifier for function parameters was
designed to prevent these from escaping, but the code below
doesn't show any errors. Is there some newer feature I should be
using? Thanks.
import std.stdio;
class Foo
{
}
class Bar
{
Foo foo;
}
void doSomething(scope Foo z, Bar b)
{
b.foo = z;
}
void main()
{
Bar b = new Bar;
scope foo = new Foo;
doSomething(foo, b);
}
More information about the Digitalmars-d-learn
mailing list