scope as storage class

Jonathan M Davis jmdavisProg at gmx.com
Thu Sep 27 09:35:29 PDT 2012


On Thursday, September 27, 2012 14:01:39 Namespace wrote:
> So you mean this code should give an error?
> 
> import std.stdio;
> 
> class A { }
> 
> A ga;
> 
> void foo(scope A a) {
> ga = a;
> }
> 
> void main() {
> A a = new A();
> 
> foo(a);
> }

Yes. You escaped a reference, which scope is supposed to prevent, but it 
rarely actually complains even though it's supposed to. Odds are that a lot of 
uses of scope (and in, since in is const scope) are going to break once scope 
has been fixed.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list