tuples and freeze dried function args
dnewsgroup at billbaxter.com
Fri Feb 23 10:50:01 PST 2007
Kevin Bealer wrote:
> You can. I do this in the futurism library, see here:
> The function make_future and the class template Future do this; the make_future
> builds a future object which stores a delegate and its arguments.
> Later, the program runs the function from these arguments. There's a lot of other
> code in that file... I think you can find a simpler example at the bottom of this
> 'Functional' programming languages call this 'currying'.
Actually they call it "partial function application"
Currying is something else often mistaken for partial evaluation.
Currying is treating a function of N args that returns Ret
func: (Arg1,Arg2,Arg3) -> Ret
as a function that does partial evaluation "to the max"
func: Arg1 -> (Arg2 -> (Arg3 -> Ret))
function that takes an Arg1 and returns
(a function that takes an Arg2 and returns
(a function that takes an Arg3 and returns a Ret))
So the call func a b c is treated as (((func a) b ) c) with currying.
In ML for instance, all functions are curried by default (but you can
sort of override the behavior by declaring your function to take a tuple
as a single argument).
Python has a partial application library that was originally called
'curry' until the functional folks shot it down as a misnomer. Now it's
More information about the Digitalmars-d-learn