[phobos] D std.bind

Jason Spencer spencer8 at sbcglobal.net
Thu Jun 17 17:34:47 PDT 2010


----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>


> I think you're close to the optimal. I'd probably drop function and 
> write:
>
> auto g1 = int(int b, int c, int d) { return g(2,b,c,d); };


That actually fails to compile in 2.047:  
curry.d(13): found '(' when expecting '.' following int


> All things considered, I'm not sure that that's worse than the 
> arcana:
>
> auto g1 = bind(&g, _1);
>
> ...
>
> All in all, std.bind looks like a direct derivative of Boost's design, which is built 
> to deal with C++'s issues, and does not avail itself of D's advantages.

It is at least shorter and comprehensible when glancing at it, though.  I'm not a great fan of the boost syntax or implementation ported to D either, but I also recognize the need for some easy way to automate that much boiler plate code.  Maybe I'll futz around and see if I can come up with a nice way of doing partial application.  If I can, could that be considered for inclusion in functional or something?

Either way, I'd politely suggest that bind should either be fixed or removed.  I assume it's been broken for 6 months now, and maybe 3 years, in D 2.0.  Seems a shame to throw away something that at least fills a hole for the time being until something better comes along, but it may be better to keep confidence in stability up.

Jason


More information about the phobos mailing list