Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-08-25 12:07:08


on Thu Aug 25 2011, "Hartmut Kaiser" <hartmut.kaiser-AT-gmail.com> wrote:

>> > Could you explain what you mean by asymmetry here? That my currying
>> > code prefers one function over another based on the available arguments?
>>
>> I mean this, for a ternary function f:
>>
>> f(x) => doesn't call f
>> f(x)(y) => doesn't call f
>> f(x)(y)(z) => calls f
>>
>> That last step looks asymmetric to me.
>>
>> In a lazy language, f(x)(y)(z) *doesn't* call f... until you actually use
>> the result for something... which is more consistent-looking.
>>
>> I suppose the symmetrical non-lazy version looks like:
>>
>> f(x) => doesn't call f
>> f(x)(y) => doesn't call f
>> f(x)(y)(z) => doesn't call f
>> f(x)(y)(z)() => calls f
>
> ... which makes it lazy again :-P

Not in the sense that I was using "lazy." I mean "lazy" in the sense that
there's no syntactic distinction between f(x) and its result, but the
computation only executes when it's finally needed.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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