On the richness of C++

Leandro Lucarella llucax at gmail.com
Mon Apr 21 08:19:03 PDT 2008


MatBec, el 16 de abril a las 15:40 me escribiste:
> Jason House Wrote:
> 
> > The only thing I'm contesting is your statement that closures eliminate the need for a bind library.  While it's true they reduce the need for a bind library, they don't eliminate it.
> 
> Instead of call some strange bind function just create a closure taking the still unbound arguments that calles the function.
> 
> 
> I'm not a d-Programmer, but in other languages this is very easy.
> 
> e.g. Haskell
> 
> 
> foo x y z = x + y + z
> 
> bar f = f 9
> 
> -- Pass bar a version of foo wich has two arguments bound
> bar \y -> foo 1 y 7

This is called partial function application[1] in Python, which includes
a module to do so[2] too. In Haskell is very natural because of the lambda
calculus[3].

C++0x will have something similar[4] for templates (which I'm not sure if
D support via alias).

[1] http://www.python.org/dev/peps/pep-0309/
[2] http://docs.python.org/lib/module-functools.html
    http://www.python.org/doc/2.5/whatsnew/pep-309.html
[3] http://en.wikipedia.org/wiki/Lambda_calculus
[4] http://en.wikipedia.org/wiki/C%2B%2B0x#Template_typedefs

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
De tan fina la condesa, por no cagarse, reza.
	-- Ricardo Vaporeso



More information about the Digitalmars-d mailing list