Boost logo

Boost :

Subject: Re: [boost] Template metaprogramming libraries
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2011-09-16 14:07:27


On Fri, Sep 16, 2011 at 6:09 PM, David Sankel <camior_at_[hidden]> wrote:
>[...]
> The reason I said that phoenix "somewhat" gets around the bind heritage
> problems, which was obscure I admit, was because phoenix's use of
> traditional bind syntax still leaves a semantic hole.
>
> If someone writes the following:
>
> template< typename F >
> auto doSomething( F f ) -> decltype(...)
> {
>  return bind( f, 15, _1)
> }
>
> And then I call doSomething elsewhere like this,
>
> doSomething( bind( g, 12, _1, _2 ) )
>
> , then the result is something most likely unexpected for the user who knows
> what doSomething means (it returns a version of f that has 15 filled in as
> its first argument (λx. λy. x(15,y))), but hasn't read its implementation.

Boost.Lambda has unlambda, which is documented to prevent exactly this problem:

  http://www.boost.org/doc/libs/1_47_0/doc/html/lambda/le_in_details.html#lambda.unlambda

With a quick search I couldn't find the phoenix equivalent of
unlambda, but I'm sure there must be.

HTH,

-- 
gpd

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