Bug 16271 – Should be able to express that a lambda returns by reference

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-12T17:15:07Z
Last change time
2019-04-07T16:18:47Z
Keywords
pull
Assigned to
No Owner
Creator
Andrei Alexandrescu

Comments

Comment #0 by andrei — 2016-07-12T17:15:07Z
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.
Comment #1 by dlang-bot — 2019-04-05T20:06:19Z
@BorisCarvajal updated dlang/dmd pull request #9558 "Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference" fixing this issue: - Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference https://github.com/dlang/dmd/pull/9558
Comment #2 by dlang-bot — 2019-04-07T16:18:47Z
dlang/dmd pull request #9558 "Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference" was merged into master: - 60251b8f0e191a8f0f5142ddd2d3807d0e06c58a by Boris Carvajal: Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference https://github.com/dlang/dmd/pull/9558