Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-08 15:42:09


Douglas Paul Gregor <gregod_at_[hidden]> writes:

> On Wed, 8 Oct 2003, David Abrahams wrote:
>> My next comment:
>>
>> lambda(X)[ let[ Y == X %plus% 3,
>> F == minus[2]
>> ].in[
>> F[Y]
>> ]
>> ]
>>
>> a. Is there a *reason* that square brackets have to be used for
>> postfix function args in lambdas?
>
> Because the "," operator wouldn't work if you use parentheses, and you'd
> be stuck with lots of overloads of operator() instead of one operator[].

Ah, thanks. That explanation should go in the docs. Also an
explanation for %plus% vs ^plus^ would be nice.

>> b. It seems like
>>
>> lambda(X)[ let[ Y == X %plus% 3,
>> F == minus[2]
>> ],
>> F[Y]
>> ]
>>
>> would be a little sweeter, syntactically speaking.
>
> I disagree with this. The "let" introduces new variable bindings within
> the scope after the ".in". I think if FC++ is to remain "true" to existing
> functional languages, it should keep the ".in".

Well, I'm familiar with lisp, where it's:

      (let ((v1 <sexpr1>) (v2 <sexpr2>) ... )
           <body-sexpr1>
           <body-sexpr2>
           ...
           <result-sexpr>)

So I'd think something like:

    let[ (Y = X %plus% 3, F = minus[2]),
         F[Y]
       ]

Would be more analagous, and terser. I don't see why "in" is of any
help.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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