[Issue 19097] Extend Return Scope Semantics

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 1 07:22:26 UTC 2018


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

--- Comment #14 from Mike Franklin <slavo5150 at yahoo.com> ---
Here's a little more about what I'm thinking:

struct S
{
    // Error: `return` must be disambiguated between `this` and `r`
    this(ref scope int* r, return scope int* p);

    // OK, `return` has been disambiguated
    this(ref scope int* r, return(this) scope int* p);
    this(ref scope int* r, return(r) scope int* p);

    // OK, only one possible *output*
    int* f(return scope int* p);

    // OK, only one possible *output*
    void f(ref scope int* r, return scope int* p);

    // Error: `return` must be disambiguated between `this` and `r`
    void f(ref scope int* r1, ref scope int* r2, return scope int* p);

    // OK, `return` has been disambiguated
    void f(ref scope int* r1, ref scope int* r2, return(r1) scope int* p);
    void f(ref scope int* r1, ref scope int* r2, return(r2) scope int* p);

    // Error: `return` must be disambiguated between the return value
    // and the `r` output parameter.
    int* f(ref scope int* r, return scope int* p);

    // OK, `return` has been disambiguated
    int* f(ref scope int* r, return(r) scope int* p);

    // OK, `return` has been disambiguated
    // `return(return)` is pretty yucky, but I can't think of anything
    // else right now.
    int* f(ref scope int* r, return(return) scope int* p);
}

--


More information about the Digitalmars-d-bugs mailing list