@@ -1242,9 +1242,18 @@ int foo(in int x, out int y, ref int z, int q);
1242
1242
$(TROW $(D out), parameter is passed by reference and initialized upon function entry with the default value
1243
1243
for its type)
1244
1244
1245
- $(TROW $(D scope), references in the parameter
1246
- cannot be escaped (e.g. assigned to a global variable).
1247
- Ignored for parameters with no references)
1245
+ $(TROW $(D scope), $(ARGS
1246
+ The parameter does not escape the function call
1247
+ (e.g. by being assigned to a global variable).
1248
+ 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.
1256
+ ))
1248
1257
$(TROW $(D return), $(ARGS Parameter may be returned or copied to the first parameter,
1249
1258
but otherwise does not escape from the function.
1250
1259
Such copies are required not to outlive the argument(s) they were derived from.
@@ -1422,10 +1431,6 @@ pure void f()
1422
1431
1423
1432
$(H3 $(LNAME2 return-ref-parameters, Return Ref Parameters))
1424
1433
1425
- $(P Note: The `return` attribute is currently only enforced by `dmd`
1426
- when the `-dip25` switch is passed.
1427
- )
1428
-
1429
1434
$(P Return ref parameters are used with
1430
1435
$(RELATIVE_LINK2 ref-functions, ref functions) to ensure that the
1431
1436
returned reference will not outlive the matching argument's lifetime.
0 commit comments