Boost logo

Boost :

Subject: Re: [boost] De Bruijn Bind (alternate bind syntax) Interest?
From: David Sankel (camior_at_[hidden])
Date: 2010-09-04 14:20:02


On Sat, Sep 4, 2010 at 2:09 AM, Scott McMurray <me22.ca+boost_at_[hidden]>wrote:

> On Fri, Sep 3, 2010 at 10:09, Dave Abrahams <dave_at_[hidden]> wrote:
> > Can someone explain to me, in English, what this technique allows me
> > to express that I couldn't otherwise?
> >
> > Is this just about allowing generic composition of lambdas?
> >
>
> It feels like it to me.
>
> What I've understood so far is that _0_n and _n are essentially the
> same,

I've changed to 1 based indexing for both the abstraction number and the
argument number.

_n in a boost.bind that isn't enclosed in another boost.bind is the same as
_1_n in DBB.
_n in an unprotected boost.bind that is enclosed in 1 other boost bind is
the same as _2_n in DBB.
_n in an unprotected boost.bind that is enclosed in an unprotected boost
bind that is enclosed in yet another unprotected boost bind is the same as
_3_n in DBB.

> but that _0_n requires a lambda to scope them explicitly (sortof
> like protect).
>

Right now for the particular case of _1_n, an enclosing lam is required, but
that need not necessarily be the case. It is similar to protect only in that
they enclose other terms, that's where the similarity ends.

> The advantage of _y_n is then that you can refer to the _ns in
> enclosing lambdas (aka outside of y protects).
>
> Am I on the right track, David?
>

Yes, that is the advantage of De Bruijn indices when compared to protects.
The enclosing lambdas' arguments can be both referred to and mixed.

David

-- 
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