On Nov 10, 2014, at 11:17 AM, Richard Smith <[email protected]> wrote:
> On 10 November 2014 11:13, John McCall <[email protected]> wrote:
> On Nov 10, 2014, at 10:56 AM, Richard Smith <[email protected]> wrote:
>> On 10 November 2014 10:30, John McCall <[email protected]> wrote:
>> On Nov 8, 2014, at 9:16 AM, Richard Smith <[email protected]> wrote:
>> > Hi,
>> >
>> > WG21 is voting on a proposal for "fold-expressions" today. These are
>> > syntactically of the form:
>> >
>> > ( .... + pack )
>> > ( pack + ... )
>> > ( p0 + ... + pack )
>> > ( pack + ... + pn )
>> >
>> > (where + can be any binary operator). These expand to
>> >
>> > (((p0 + p1) + ...) + pn)
>> >
>> > for the first and third cases and
>> >
>> > (p0 + (p1 + (... + pn)))
>> >
>> > for the other two cases.
>>
>> I should add:
>> - in the first and second cases, the pack is p0 ... pn
>> - in the third case, the pack is p1 ... pn
>> - in the fourth case, the pack is p0 ... p{n-1}
>
> Your notation is terrible, Richard. :)
>
> Yeah, sorry. I should have just attached the paper rather than trying to
> summarize. (Now attached.)
>
> Okay, so the idea is that:
> E op … op P => (((E op P1) op P2) op …) op Pn
> P op … op E => P1 op (P2 op (… op (Pn op E)))
>
> How are E and P determined? Everything preceding/following the … term, or
> does this actually follow the grammar’s associativity rules if you had e.g.
> 1+2+…+packref+3+4
> or does it only work within parentheses?
>
> Parentheses are required, and only cast-expressions are allowed before /
> after the operators, so there are no precedence / associativity issues. (The
> initial proposal was deliberately very conservative in this regard.)
Okay, makes sense.
>> > These need a mangling; I suggest (and have implemented):
>> >
>> > <expression> ::=
>> > fl <binary operator-name> <expression> # ( ... op pack )
>> > fr <binary operator-name> <expression> # ( pack op ... )
>> > fx <binary operator-name> <expression> <expression> # ( expr op ... op
>> > expr )
>>
>> This doesn’t seem to correspond to one of your examples.
>>
>> You get this for the third and fourth cases.
>
> Okay, and you’re saying that left/right folding are disambiguated because one
> of the expressions contains a pack and the other doesn’t? I think I would
> prefer this to be explicit in the mangling.
>
> OK. Then fl / fr / fL / fR?
Sounds good to me.
John.
_______________________________________________
cxx-abi-dev mailing list
[email protected]
http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev