October 24, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 | <dhasenan@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dhasenan@gmail.com --- Comment #11 from | <dhasenan@gmail.com> --- @safe void betty(bool b, ref scope int* r, return scope int* p) { if (b) r = p; } betty("", q, &i); This is not going to work, I take it? Is that desirable? -- |
December 01, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #12 from Mike Franklin <slavo5150@yahoo.com> --- I'm wondering if it might be possible to do something like this: ``` void betty(ref scope int* r, return(r) scope int* p) { r = p; } ``` `return(r)` explicitly ties p's lifetime to r's. So, the `return` attribute would take an argument specifying which "output" parameter to tie the input lifetime to, and the semantics no longer rely on convention or the order of arguments. -- |
December 01, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #13 from Mike Franklin <slavo5150@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); } -- |
December 01, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #14 from Mike Franklin <slavo5150@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); } -- |
December 01, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #15 from Mike Franklin <slavo5150@yahoo.com> --- I think in my prior example, I may have overlooked the implicit `this` argument for member functions. Here I attempt to compensate. //------------------------------------------------ // 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); 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); //------------------------------------------------ // Error: `return` must be disambiguated between `this` and `r` void f(ref scope int* r, return scope int* p); // OK, `return` has been disambiguated void f(ref scope int* r, return(this) scope int* p); // OK, `return` has been disambiguated void f(ref scope int* r, return(r) scope int* p); //------------------------------------------------ // Error: `return` must be disambiguated between `this`, `r1`, and `r2` 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 `this` and the return value int* f(return scope int* p); // OK, `return` has been disambiguated int* f(return(this) scope int* p); // OK, `return` has been disambiguated - tied to return value int* f(return(return) scope int* p); } Hopefully, you get the idea. -- |
December 30, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #16 from Walter Bright <bugzilla@digitalmars.com> --- Partial: https://github.com/dlang/dlang.org/pull/2535 -- |
December 30, 2018 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #17 from github-bugzilla@puremagic.com --- Commits pushed to master at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/6299e9193986cb7f9accf1a3059115145b8a938d add initial documentation for issue 19097 https://github.com/dlang/dlang.org/commit/140267d3cf3b6ea4977853a0c017f5f81b3ce287 Merge pull request #2535 from WalterBright/fix19097-1 add initial documentation for issue 19097 merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com> -- |
January 05, 2019 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 --- Comment #18 from github-bugzilla@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/326e50b04a69e3eaebab54229ae44c4ac60579f2 fix Issue 19097 - Extend Return Scope Semantics https://github.com/dlang/dmd/commit/4719804f54d67e51a4fb8cb413c5aa9506126f9f Merge pull request #8504 from WalterBright/fix19097 fix Issue 19097 - Extend Return Scope Semantics -- |
January 05, 2019 [Issue 19097] Extend Return Scope Semantics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19097 github-bugzilla@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED -- |
Copyright © 1999-2021 by the D Language Foundation