Use case for std.bind
Daniel Keep
daniel.keep.lists at gmail.com
Tue Feb 24 05:46:21 PST 2009
Lars Kyllingstad wrote:
> [snip]
>
> I for one like it, and would very much like to see such a syntax in D2.
> Also, I'd have it work with either of a function's arguments, not only
> the leading or trailing ones:
>
> int foo(int a, int b, int c, int d) {...}
> auto bar1 = foo(_, b, c, d);
> auto bar2 = foo(a, b, c, _);
> auto bar3 = foo(_, b, _, d);
>
> assert (is (typeof(bar3) == int delegate(int, int)));
>
> In its simplest form, it would just be syntactic sugar for the delegate
> literal. But I'm curious: If foo is a pure function, couldn't the
> compiler perform some extra optimization here?
>
> -Lars
auto a = b(_, c(_, x), _);
What are the types of a, b and c? What if b has multiple overloads or
is templated?
Context-dependant grammar (let alone context-dependant single character
symbols): just say "no".
-- Daniel
More information about the Digitalmars-d
mailing list