
On Fri, Sep 3, 2010 at 11:13 PM, Joel de Guzman <joel@boost-consulting.com>wrote:
On 9/4/2010 10:40 AM, David Sankel wrote:
Your lambda uses brackets and I'm assuming this is for sequencing zero argument procedures.
Yeah. It's use and syntax is historical. The intent is to be as close as possible to C++ and to somehow emulate C++ statements. It is used that way, e.g.:
if_(c) [ dothis() ] .else_ [ dothat() ]
It's not only for the sake of being clever. More importantly, C++ users connect to this easily compared to other concocted means. It is instantly recognizable.
I think there's virtue in using syntactic sugar to expose a lambda calculus engine in a way that resembles C++ code. My focus for DBB is to create a powerful, yet simple, engine that, among other things, others can build syntax sugar on top of -- whether that be a C++ resembling lambda syntax or functional reactive programming syntax. As an aside, I taught a fork of DBB a new trick today, fix[1]. This enables one to declare recursive functions like factorial and fib. With some syntax sugar this could be quite nifty: //llam → lazy lambda is only evaluated when needed //_a_b → the b argument of the a nested lambda //_a → the a nested lambda auto fact = iff( _1_1 == 1 , 1 , llam( _2_1 * _2( _2_1 - 1 ) ) ) ⇒ syntax sugar traslated to fix fix( lam( lam( iff( _1_1 == 1 , 1 , llam( _2_1 * _3_1( _2_1 - 1 ) ) ) ) ) ); I'm also pretty confidant I can make the evaluator do tail call optimization [1] http://en.wikipedia.org/wiki/Fixed_point_combinator [2] http://en.wikipedia.org/wiki/Tail_call#Tail_call_optimization -- David Sankel Sankel Software www.sankelsoftware.com 585 617 4748 (Office)