Boost logo

Boost :

Subject: Re: [boost] De Bruijn Bind (alternate bind syntax) Interest?
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-09-03 23:13:30


On 9/4/2010 10:40 AM, David Sankel wrote:

>> Assuming phoenix::outer is reinstated, and assuming we have predefined
>> placeholders for the most common arities and scopes (e.g. 1..10 args
>> and 1..3 scopes), the phoenix equivalent would then be:
>>
>> for_each(_1,
>> lambda
>> [
>> push_back(_1, _2_1)
>> ]
>> )
>>
>> Very close to your syntax.
>
>
> Indeed we are converging. I like code that is made up of independently
> useful and simple pieces that are composed together in powerful ways.

Yep. That's the mantra of Phoenix.

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

> So I'd make a separate function which would be useful
> for that (Instead of brackets, I'd use normal function calls with variadic
> templates for the same effect).
>
> So
>
> seq(a,b,c...) => { a(); b(); c();...}
>
> lambda would be kept simple, as a single argument, and maybe a lamseq could
> be
>
> auto lamseq = lamAppPrim( seq );
>
> And then we get a true equivalence:
>
> for_each(_1,
> lamseq
> (
> push_back(_1, _2_1)
> )
> )
>
>
> Why keep outer if you have scoped_argument?

Agreed. outer is(was) built on top of scoped_argument anyway.

Regards

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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