
On Mon, Sep 20, 2010 at 10:57 AM, David Sankel <camior@gmail.com> wrote:
On Sun, Sep 19, 2010 at 2:51 PM, Larry Evans <cppljevans@suddenlink.net>wrote:
On 09/02/10 10:57, David Sankel wrote:
Hello all,
I've been working on an alternate bind syntax based on De Bruijn indices[1]. The syntax is very simple, yet the terms are very powerful.
David,
I tried the problem on:
http://en.wikipedia.org/wiki/De_Bruijn_index
however, I'm getting the compile errors shown in the attachment which also shows the source via a cat command.
Any ideas what may be wrong?
Larry,
Looks like you passed a template function, z, to another function. <snip> Looks like there are more issues too. I'll continue digging.
The example, (λ λ z 2 (λ 1 3)) (λ w 1) is a tough one to comprehend, but certainly implementable: auto t = lam<1>( lam<1>( app( z2 , _2_1 , lam<1>( app( _1_1 , _3_1 ) ) ) ) ) ( lam<1>( app( w, _1_1 ) ) ); int result = t("ignored"); If I implemented the "To make our eager evaluator consistent" TODO, I could use the app(a,b) syntax instead of the a(b) syntax for the final application. This gives the expression more consistency: auto t = app( lam<1>( lam<1>( app( z2 , _2_1 , lam<1>( app( _1_1 , _3_1 ) ) ) ) ) , lam<1>( app( w, _1_1 ) ) ); The z function in the example is a weird beast. I gave it a trivial implementation: struct Z2 { typedef int result_type; template < typename F, typename G > int operator()( F f , G g ) const { return 3; }; } const z2 = Z2(); To make a non-trivial implementation of z, you could use the fact that its first argument has kind * → *. That is, its first argument must be a function from something to something. Its second argument has kind ((* → *) → *) → *). That is, its second argument must be a function that takes in a function as its first parameter that takes in a function as its first parameter. A fun mind bender :). David -- David Sankel Sankel Software www.sankelsoftware.com 585 617 4748 (Office)