[Issue 9426] [enh] polymorphic lambda should be aliasable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 31 05:49:44 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9426


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #3 from bearophile_hugs at eml.cc 2013-07-31 05:49:42 PDT ---
Now the D language supports enum and alias used as lambdas, so adding template
function lambdas seems good:


import std.typecons: Tuple;
void main() {
    alias Pair(T) = Tuple!(T, T); // OK
    auto p = Pair!int(10, 20);
    enum isGood(T) = is(T == int) || is(T == long); // OK
    static assert(isGood!int);
    enum foo(T) = (T x) => x * x; // OK
    static assert(foo!int(5) == 25);
    alias bar = x => x * x; // Error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list