Use case for std.bind
Jason House
jason.james.house at gmail.com
Mon Feb 23 14:11:02 PST 2009
downs Wrote:
> Let me say first that I don't use std.bind myself, but tools.base:fix fills essentially the same need - creating full closures from dynamic ones.
>
> Say you have a function that takes a number and returns a delegate that does something with that number.
>
> void delegate() test(int i) { return { return i + 2; }; }
>
> In 2.0 this will ......................
>
> Oh.
>
> Nevermind. I don't know what to use bind for after all :)
>
> In fact, I suspect it's essentially useless in 2.0. Creating full closures was my only use case :)
I look at bind as the difference between by reference and by value semantics. When using scope delegates (or delegates that could be scope delegates), this difference rarely matters. When passing data between threads, the need to pass by value becomes more important. "By value" may even require a deep copy.
Even though I can see uses for some kind of bind functionality in D2, I need to see where all this "shared" object stuff goes before I know what/if a D2 bind library should do.
More information about the Digitalmars-d
mailing list