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);
}

Reply via email to