On Sat, Jun 6, 2009 at 11:17 AM, Steven Schveighoffer<schvei...@yahoo.com> wrote: >> >> You need to do escape analysis and whole program analysis to determine >> whether there are aliases to a scope member. Failing that, it's pretty easy >> to introduce bugs that are difficult to find. > > Not really. A scope member would be placed in the same memory block as the > owner class. So an alias to the member would be the same as an alias to the > owner class because the same memory block would be referenced. Both > wouldn't be collected until neither is referenced.
Regardless of how/where it's allocated, Chris is still right, unless 'scope' becomes a type constructor instead of a storage attribute. Consider: class A { void fork() { writeln("fork!"); } } class B { scope A a; this() { a = new A(); } } A a; void foo() { scope b = new B(); a = b.a; // waaait } void main() { foo(); a.fork(); // AGHL } If it were impossible to assign a "scope A" into an A, this wouldn't be a problem. Or, full escape analysis, either way.