Use case for std.bind

Jason House jason.james.house at gmail.com
Wed Feb 25 17:23:59 PST 2009


Andrei Alexandrescu wrote:

> Jason House wrote:
>> The first follow-up to your reply captured the kind of messiness bind
>> can bring in C++. So far, all your examples are trivial (lack
>> argument reordering, function composition, etc...). It's true that
>> your examples look clean, but the devil will be in the details.
> 
> I see. The only problem is that very few people seem to use std.bind;
> there are few interesting examples of arbitrary partial argument binding
> that need formalization. The one good example I know of is those float
> vector permutations, but nobody in their right mind would use a delegate
> for that!

I was one of those people using bind when I was using D1, and I didn't 
actually use std.bind...

I think what is really needed before a design contest is to know what the 
use cases are.  If there's only one use case, I'd argue that completely 
generic terms such as curry are not appropriate.


> That all makes it even more appealing to stick with a five-liner in
> std.functional that gets currying into the bag (which is a useful and
> low-hanging fruit) and call std.bind history. Makes sense?

The few lines of code for a single case does make sense.  I can't yet figure 
out what you're thinking the final product should be or what it should do.  
When talking about bind, I think of boost::bind (or std::bind).  When 
thinking of that, I envision all the ugly combinations that can arise.  I 
usually think of delegates as solving those cases better.

I also would have assumed that when you talked about small structs that 
you'd be using the opCall trick (or similar).  Of course, we all know you 
don't like adding parenthesis at the end, so maybe a function name would be 
better ;)

... so no, it doesn't make sense.  




More information about the Digitalmars-d mailing list