Proposal for design of 'scope' (Was: Re: Opportunities for D)

Meta via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 10 18:05:16 PDT 2014


On Thursday, 10 July 2014 at 18:16:57 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> There is an interesting subtlety here, in that local variables
> themselves are not necessarily scoped, for example:
>
> 	class C {}
> 	C createObj() {
> 		auto obj = new C;	// obj is a local variable
> 		return obj;		// but its lifetime can be extended outside the 
> function
> 	}

They are scoped, but to the lifetime of the GC, which is the 
length of the program. Anything that the GC owns can safely be 
marked scope(static) or however you would write it.


More information about the Digitalmars-d mailing list