Boost logo

Boost :

Subject: Re: [boost] De Bruijn Bind (alternate bind syntax) Interest?
From: David Sankel (camior_at_[hidden])
Date: 2010-09-03 11:39:47


On Fri, Sep 3, 2010 at 7:50 AM, Stefan Strasser <strasser_at_[hidden]>wrote:

> david, why do you need to number the lambdas? doesn't the "nested index"
>> of the args refer to the level of nesting instead of the number given to
>> the lam<> template?
>>
>
> after reading the link larry posted (1), let me correct my question:
> does lam need to know the number of parameters of the resulting function?
>
> Boost.Bind simply ignores additional arguments, and generates a compiler
> error for insufficient arguments.
>
> void f(int,int);
> bind(&f,3,_1)(1,2); // -> f(3,1)
>

It is possible to make the semantics such that lam does not need to know the
number of parameters of the resulting function. Instead of returning a
function with a set arity it will return a function with many arities, like
bind does.

My preference is for a set arity return value. Every time I've used bind
I've always had a specific arity in mind and its current behavior has been a
source of subtle run-time bugs. If someone really wants a multi-arity
function then they can use another tool to do that:

make_multi_arity( lam<1>( _1_1 ) );

Furthermore it really complicates the simple semantics we have. That would
make me sad :(

-- 
David Sankel
Sankel Software
www.sankelsoftware.com
585 617 4748 (Office)

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