[Issue 19097] Extend Return Scope Semantics

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 1 06:13:21 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19097

--- Comment #13 from Mike Franklin <slavo5150 at yahoo.com> ---
For constructors, one could use `return(this)` to the same effect. Perhaps for
constructors, if there are no other "output" parameters in the signature,
`return(this)` could be inferred by simply typing add `return` to the input
parameters.  If there is more than one "output" parameter, the user would have
to explicitly disambiguate by adding an argument to the `return` attribute.

struct S
{
    // does `return` apply to `this` or `r`?
    this(ref scope int* r, return scope int* p);

    // disambiguate by explicitly adding an argument to `return`
    this(ref scope int* r, return(this) scope int* p);
    // or
    this(ref scope int* r, return(r) scope int* p);
}

--


More information about the Digitalmars-d-bugs mailing list