Bug 12421 – Allow simpler syntax for lambda template declarations

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-20T03:23:00Z
Last change time
2016-01-03T14:20:07Z
Keywords
pull
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2014-03-20T03:23:28Z
----- void main() { import std.algorithm; import std.traits; { static auto notEmpty(Arr)(Arr arr) { return !arr.filter!(a => a > 0.0).empty; } assert(notEmpty([0.0, 0.0, 0.1])); } { // simpler syntax should be supported alias notEmpty = a => a.filter!(b => b > 0.0).empty; assert(notEmpty([0.0, 0.0, 0.1])); } } ----- Note how much code has to be written for a "throwaway" inline function definition in the first case. This could be simplified by supporting the second syntax.
Comment #1 by andrej.mitrovich — 2014-03-20T03:24:24Z
A slightly more fair comparison if we take into account that 'static' acts as 'auto': ----- void main() { import std.algorithm; import std.traits; { static notEmpty(A)(A a) { return !a.filter!(b => b > 0.0).empty; } assert(notEmpty([0.0, 0.0, 0.1])); } { // simpler syntax should be supported alias notEmpty = a => a.filter!(b => b > 0.0).empty; assert(notEmpty([0.0, 0.0, 0.1])); } } -----
Comment #2 by k.hara.pg — 2014-06-07T11:46:47Z
Comment #3 by k.hara.pg — 2014-06-07T12:00:59Z
Comment #4 by k.hara.pg — 2014-06-09T04:56:32Z
*** Issue 7308 has been marked as a duplicate of this issue. ***
Comment #5 by code — 2014-07-04T22:59:28Z
*** Issue 9426 has been marked as a duplicate of this issue. ***
Comment #6 by dlang-bugzilla — 2015-06-26T12:29:03Z
Workaround: alias I(alias X) = X; alias notEmpty = I!(a => a.filter!(b => b > 0.0).empty); http://blog.thecybershadow.net/2015/04/28/the-amazing-template-that-does-nothing/
Comment #7 by github-bugzilla — 2015-10-13T12:36:02Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/445e1734f450f8e4a5c2f38b5ad0dfe2c937f897 fix Issue 12421 - Allow simpler syntax for lambda template declarations https://github.com/D-Programming-Language/dmd/commit/78820390932309c1c5503770ebcaec338bd69b88 Merge pull request #3638 from 9rnsr/fix12421 Issue 12421 - Allow simpler syntax for lambda template declarations
Comment #8 by github-bugzilla — 2015-11-01T12:07:21Z
Commits pushed to stable at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/dc8edfebf6bf9b48bcf33b2e79c0ed305ec2fde0 fix Issue 12421 - Allow simpler syntax for lambda template declarations https://github.com/D-Programming-Language/dlang.org/commit/72ed432292028ff55caef307c5abee5cb97eb199 Merge pull request #1147 from 9rnsr/fix12421 Issue 12421 - Allow simpler syntax for lambda template declarations
Comment #9 by github-bugzilla — 2015-11-02T00:46:25Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/9446e513e4ba1b984d03b159ad0820c1e58024d5 fix Issue 12421 - Allow simpler syntax for lambda template declarations https://github.com/D-Programming-Language/dlang.org/commit/5d2f9dfd8a496896e22bf227855b6de9629b3f71 Merge pull request #1148 from MartinNowak/alias_funclit fix Issue 12421 - Allow simpler syntax for lambda template declarations
Comment #10 by github-bugzilla — 2015-11-11T11:45:42Z
Comment #11 by github-bugzilla — 2016-01-03T14:01:49Z
Comment #12 by github-bugzilla — 2016-01-03T14:20:07Z