Skip to content

Commit 90b2561

Browse files
committed
Move note; scope avoiding heap-allocation is only potential
1 parent 4f84311 commit 90b2561

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

spec/function.dd

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,16 +1243,17 @@ int foo(in int x, out int y, ref int z, int q);
12431243
for its type)
12441244

12451245
$(TROW $(D scope), $(ARGS
1246-
The parameter does not escape the function call
1246+
The parameter must not escape the function call
12471247
(e.g. by being assigned to a global variable).
12481248
Ignored for any parameter that is not a reference type.
1249-
Escape analysis is only done for `@safe` functions, for other functions `scope` semantics must
1250-
be manually enforced.
1251-
As the parameter must not escape, the compiler can avoid heap-allocation of a unique argument
1252-
to a `scope` parameter. Due to this, passing e.g. a `new T` argument may not violate `@nogc`.
1253-
A typical example of this is passing a delegate literal to a `scope` parameter.
1254-
$(B Note): `scope` escape analysis is currently only done by `dmd`
1255-
when the `-dip1000` switch is passed.
1249+
`scope` escape analysis is only done for `@safe` functions. For other functions `scope`
1250+
semantics must be manually enforced.)
1251+
$(P $(B Note): `scope` escape analysis is currently only done by `dmd`
1252+
when the `-dip1000` switch is passed.)
1253+
$(P As the parameter must not escape, the compiler can potentially avoid heap-allocation of a
1254+
unique argument to a `scope` parameter. Due to this, passing an array literal, delegate
1255+
literal or a $(GLINK2 expression, NewExpression) to a scope parameter may be used in a
1256+
`@nogc` context, depending on the compiler implementation.)
12561257
))
12571258
$(TROW $(D return), $(ARGS Parameter may be returned or copied to the first parameter,
12581259
but otherwise does not escape from the function.

0 commit comments

Comments
 (0)