[J3] Question about the conditional expression syntax in 21-157r2

Thomas König tk at tkoenig.net
Wed Jun 30 21:49:32 UTC 2021


> So IMO,
>     special parens = best
>     ordinary parens = acceptable 
>     no parens = unacceptable

If I may make a suggestion...

One possibility would be to prohibit a cond-expr as part of a cond-expr.


   cond1 ? (cond2 ? expr : expr2) : expr3

would be permitted, but

   cond ? cond2 ? expr : expr2 : expr3

or nested conditions would not be.

It would probably be necessary to add an extra level of expressions to
the syntax rules for this, something like

defined-binary-op-expr is [ defined-binary-op-expr defined-binary-op ] 


cond-expr is defined-binary-op-expr ? defined-binary-op-expr : 

expr is cond-expr or defined-binary-op-expr

(I think this grammar would be unambiguous, I hope I'm right).

Best regards


More information about the J3 mailing list