Why is 'scope' so weak?

dsimcha dsimcha at yahoo.com
Tue Nov 23 06:56:35 PST 2010


== Quote from Lars T. Kyllingstad (public at kyllingen.NOSPAMnet)'s article
> Considering that the compiler enforces proper use of pure, nothrow,
> const, and all those other things, it doesn't seem much harder to do the
> same with scope.

I haven't thought through all the implications yet, but at first glance making
scope a transitive type constructor that is only valid for local variables and
function parameters, but not global or member variables, seems like an interesting
idea.  In the case of structs, I guess a member variable could be scope if and
only if the struct is a local variable and the member variable inherits the scope
attribute.  In any case, member variables would never be directly taggable as
scope, since structs could be heap-allocated.

I guess the rule would be that non-scope can implicitly convert to scope (since
something that lives on the heap can be safely used anywhere) but not the other
way around?


More information about the Digitalmars-d mailing list