Escape analysis
Walter Bright
newshound1 at digitalmars.com
Tue Oct 28 15:07:45 PDT 2008
Sean Kelly wrote:
> I do think, however, that 'scope' should be the default behavior, for
> two reasons. It's backwards-compatible, which is handy. But more
> importantly, I'd say that probably 95% of the current uses of delegates
> are scoped, and that isn't likely to shift all the way to 50% even if D
> moved to a much more functional style of programming. Algorithms, for
> example, all use scoped delegates, which I'd say is far and away their
> most common current use.
The counter to that is that when there is an inadvertent escape of a
reference, the error is often undetectable even while it silently
corrupts data and behaves erratically.
In other words (as Andrei pointed out to me) the cost of those errors,
even though rare, is very high. This makes it highly desirable to
prevent them automatically, rather than relying on the skill and
attention to detail of the programmer.
Contrast that with, say, a null pointer bug which results in an
unambiguous sudden halt to the program with a clear indication of what
happened.
The 'scope' storage class also has a future in that it is possible using
data flow analysis to statically verify it.
More information about the Digitalmars-d
mailing list