Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-09 08:44:30


Brian McNamara <lorgon_at_[hidden]> writes:

> On Wed, Oct 08, 2003 at 10:24:05PM -0400, David Abrahams wrote:
>> After some more thought, I have a question: what's the meaning of:
>>
>> // f(x) -> 2*(x+3)
>> lambda(X)[
>> let[
>> Y == X %plus% 3 // y = x+3
>> , Fun == multiplies(2) // fun(x) -> 2*x NOTE PARENS
>> ].in[
>> Fun[Y] // fun(y)
>> ]
>> ]
>>
>> ??
>>
>> if it's the same as
>>
>> // f(x) -> 2*(x+3)
>> lambda(X)[
>> let[
>> Y == X %plus% 3 // y = x+3
>> , Fun == multiplies[2] // fun(x) -> 2*x NOTE BRACKETS
>> ].in[
>> Fun[Y] // fun(y)
>> ]
>> ]
>
> It is the same. More generally, inside a lambda expression,
>
> f(cppexpr) = f[cppexpr]
>
> holds true for all "f" which do not cause side-effects. (Subject to
> the constraint that "cppexpr" is a C++ expression, and not a lambda
> expression. When "cppexpr" is a lambda expression--let's now call it
> "lexpr" instead--"f(lexpr)" usually doesn't compile, and when it does,
> it typically means something different than "f[lexpr]".)

Yeah, I was talking about the specific case where you're currying as
in multiplies[2].

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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