scope keyword - a maintenance nightmare?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Aug 18 06:26:46 PDT 2007


"Guenther Brunthaler" <gb at dont.spam.me.invalid> wrote in message 
news:fa610v$1j33$1 at digitalmars.com...
>
> If di files only were part of the language rather than optional 
> extensions!

But they _are_, as far as I know, part of the language.  They're probably 
just not documented as well as they could be (like many other features).

> I actually assumed the "scope" keyword would work in a quite similar way 
> in D!
>
> But, if i got you right, are you suggesting "scope" only works on a 
> lexical scope basis?
>
> That it, a "scope" class object's lifetime does *not* depend on the 
> lifetime of the object the variable is allocated within (such as the 
> lexical scope *or* another object), but is *always* controlled by the 
> lifetime of the lexical scope only?

You've got it right, and I agree, we need 'scope' to be extended to mean 
'the lifetime of this object is dependent upon where it was created'.  It 
would probably greatly reduce the need for the GC in many instances in fact, 
leaving the GC to deal with true garbage, rather than objects which just 
happened to be orphaned when the data structure they were part of was no 
longer needed. 





More information about the Digitalmars-d mailing list