----- 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.
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])); } } -----
https://github.com/D-Programming-Language/dmd/pull/3638
Spec change: https://github.com/D-Programming-Language/dlang.org/pull/589
*** Issue 7308 has been marked as a duplicate of this issue. ***
*** Issue 9426 has been marked as a duplicate of this issue. ***
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/
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
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
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
Commits pushed to master 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
Commits pushed to stable 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
Commits pushed to stable 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