[Issue 15732] std.function partial does not work with function / delegate references

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 24 14:10:28 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=15732

ZombineDev <petar.p.kirov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov at gmail.com

--- Comment #3 from ZombineDev <petar.p.kirov at gmail.com> ---
Since the https://github.com/dlang/phobos/pull/6497 was merged, a fixed version
of the example above compiles:

auto partial_application () {
    // definition of a basic function on 3 parameters using lambda syntax
    auto basic = (float a, float b, float c) => a + b / c;

    // partially apply value to basic    
    import std.functional : partial;
    alias partial!(basic, 1) apply1;

    return &apply1; // now OK, didn't compile before
}

void main(string[] args) {

    auto test = partial_application();

    import std.stdio : writeln;
    writeln("result: ", test(2, 3)); // 1 + (2/3) = 1.66667
}

I see no reason why the GitHub -> Bugzilla integration didn't close the issue
automatically, so I'm closing it manually.

--


More information about the Digitalmars-d-bugs mailing list