Boost logo

Boost :

Subject: Re: [boost] De Bruijn Bind (alternate bind syntax) Interest?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-09-02 13:46:01


On 09/02/10 12:10, Stewart, Robert wrote:
> David Sankel wrote:
>>
>> I've been working on an alternate bind syntax based on De
>> Bruijn indices[1].
>
> I started to look at the Wikipedia page, but realized there was way too much for me to learn to even begin to understand what you mean. Therefore, this reference is of no value to anyone without your background.
>
>> The syntax is very simple, yet the terms are very powerful.
>
> I must take your word for it.
>
>> Here is an example of a function const that takes in an argument c and
>> returns another function that, for all input, returns c:
>>
>> //ëx.ëy.x = ëë1 with De Bruijn indices.
>> auto const_ = abs<1>( abs<1>( var<1,0>() ) );
>
> Presumably, "abs" doesn't mean absolute value as it would in pretty much any other programming context. That seems unwise at best.

Hmm... That puzzles me too, but maybe it's an alias for lambda.
I think its meant to suggest ABSstraction? The abs<1> term
maybe corresponds to the

  \1.body

(Where \ means the lambda greek letter) and
  (\1.body)(x)
=> body with x substituted for the 1 "variable"
   because, as explained on the wiki page, variables
   are represented by positive natural numbers.

This is sorta like with the current:

   mpl::apply(mpl::arg<I>,arg1,arg2,...,argn)::type

=> argI

I think this use of DeBruijn notation would avoid some of
the problems I had using mpl when the expressions got
a little too complicated and I had to resort to using
lambda and I think something else to avoid, what I guess
was, variable capture causing problems.

Good luck David!

-regards,
Larry


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