[Issue 16271] New: Should be able to express that a lambda returns by reference
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jul 12 10:15:07 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16271
Issue ID: 16271
Summary: Should be able to express that a lambda returns by
reference
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: andrei at erdani.com
This literal takes one parameter by ref and the other by value, and returns by
value:
(ref x, y) { x += y; return x; }
function (ref x, y) { x += y; return x; } // alternative
There is no way to specify that we want it to return e.g. x by reference. These
syntaxes do not work:
function ref (ref x, y) { x += y; return x; }
function ref typeof(x) (ref x, y) { x += y; return x; }
I think the first one should work. For that, the "return" attribute will also
be deduced.
--
More information about the Digitalmars-d-bugs
mailing list