Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Maxim Yanchenko (MaximYanchenko_at_[hidden])
Date: 2011-09-05 07:10:05


Larry Evans <cppljevans <at> suddenlink.net> writes:

> Then so is (using haskell notation):
>
> f :: X -> Y -> Z -> int
>
> f x => returns Y -> Z -> int
> f x y => returns Z -> int
> f x y z => returns int
>
> which is Eric's point. IOW, when supplied with enough arguments,
> the function returns the result_type of the function, just as,
> when a multi-dimensional array is supplied enough arguments
> (or indices) it returns the value type of the array.

Exactly. All this applies to return types only. It doesn't apply at all to when
the function will be actually evaluated. And this is essentially the Dave's
point (IIUC).

Consider printf, for example, either vararg or variadic template version.
Or any other function with default arguments.
How should it look like with automatic currying/evaluating based on the number
of the arguments provided?

Also it's unclear even when we finally have passed the final argument - do we
want evaluation or we want to have a nullary function?
In Haskell, everything is lazy and functions are pure so it doesn't matter when
and how many times you evaluate them. C++ is very different here.

I'm on Dave's side here: we should be explicit about the time when we want to
trigger actual evaluation.

Thanks,
Maxim


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk