ref is unsafe
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jan 3 15:47:02 PST 2013
On Thursday, January 03, 2013 23:50:37 Rob T wrote:
> My understanding was that in some cases that source code is not
> available to the compiler, which I would think means that
> preventing scope escaping cannot be 100% guaranteed, correct?
The source code is always available when compiling the function itself. So
(assuming that scope is fully implemented - which it's not right now), the
compiler will be able to verify that a scope parameter does not escape the
function when it compiles that function.
What doesn't work is inferring function attributes at the call site, because
that requires that the full code be available at the call site. And that's not
necessarily true unless you're dealing with a templated function (which is
part of why attribute inferrence only works with templated functions). But as
long as you're talking about stuff that can be verified when the function itself
is compiled, then the fact that the source code isn't necessarily available to
the caller isn't an issue.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list