Escape analysis

Jason House jason.james.house at gmail.com
Tue Oct 28 06:02:42 PDT 2008


Michel Fortin Wrote:

> On 2008-10-28 00:28:27 -0400, Walter Bright <newshound1 at digitalmars.com> said:
> 
> > Jason House wrote:
> >> Walter Bright wrote:
> >>> scope is a storage class, not a type constructor.
> >> 
> >> How do you treat members of objects passed in? If I pass in a struct
> >> with a delegate in it, is it treated as scope too? What if it's an
> >> array? A class?
> > 
> > The scope applies to the bits of the object, not what they may refer to.
> 
> So basically, we always have head-scope. Here's my question:
> 
> 	int** a;
> 
> 	void foo() {
> 		scope int b;
> 		scope int* c = &b;
> 		scope int** d = &c;
> 		a = &c; // error, c is scope, can't copy address of scope to non-scope.
> 		a = d; // error? d is scope, but we're only making a copy of its bits.
> 		       // It's what d points to that is scope, but do we know about that?
> 	}

Your assignment to c discards the scope protection. Taking the address of scope variables should be an error.



> 
> In this case, it's obvious that the last assignment (a = d) is bogus. 
> Is there any plan in having this fail to compile? If so, where does it 
> fail?
> 
> -- 
> Michel Fortin
> michel.fortin at michelf.com
> http://michelf.com/
> 




More information about the Digitalmars-d mailing list