On Sunday, November 11, 2012 13:36:05 Dmitry Olshansky wrote: > Nope. It's just that the stack is intact and contains: hello and goodbye > one after another. Without optimizations { } scope doesn't mean reuse > stack space. > > Now if play with stack a bit, for me the next one prints: > -²↑ > > import std.stdio; > > void delegate() global; > > void foo(scope void delegate() del) > { > global = del; > } > > > void f() > { > { > char[5] bar = "hello"; > foo((){writeln(bar);}); > } > } > > void main() > { > char[7] baz = "goodbye"; > f(); > > global(); > }
It still prints "hello", even with full optimations turned on. So, it must be allocating a closure in spite of scope. So, it looks to me like scope is just completely ignored and does absolutely nothing at this point, unless I'm just completely missing something here. - Jonathan M Davis