|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-10-08 16:45:51
"Powell, Gary" <powellg_at_[hidden]> writes:
> Dave Abrahams wrote:
> -----------------------------------------------------------------
> a. Is there a *reason* that square brackets have to be used for
> postfix function args in lambdas?
>
> b. It seems like
>
> lambda(X)[ let[ Y == X %plus% 3,
> F == minus[2]
> ],
> F[Y]
> ]
>
> would be a little sweeter, syntactically speaking.
> -----------------------------------------------------------------
>
> isn't there a parsing issue here? Where the "," impiles two arguments
> to the Lambda(X)[] function call
Uhm, operator[] can only take a single argument in C++
> when you really want one fc++Lambda object from binding the ","
> first. which makes you write:
>
> lambda(X)[ (
> let[ Y == X %plus% 3,
> F == minus[2]
> ],
> F[Y]
> )
> ]
I don't see how that changes the parsing.
IIUC Foo[expr1, expr2] is always parsed as
Foo.operator[](operator,(expr1, expr2))
which is equivalent to
Foo.operator[]((operator,(expr1, expr2)))
and
Foo[(expr1, expr2)]
> which for me is worse. As the let has to generate an object that is
> unique enough to be recongnized to bind to the F[Y] and generate
> useful compiler errors otherwise.
Well, that part is true, and I'll admit I haven't thought about the
possible implementation problems at that level.
> Note: my opinion is really biased as Jaakko and I came up with a
> different syntax.
I guess the number of reinvented wheels we have in overlapping
domains is starting to worry me a bit here, though I'm not ready to
object yet.
-- 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