Hi, On Thu, 16 Jul 2015, Richard Biener wrote:
> > Similar, if the condition is an atom you should be able to leave the > > parens away: > > > > (switch > > cond (minus @0 @1) > > ) > > > > (given a predicate 'cond' defined appropriately). > > Yes. Though techincally the condition cannot be an atom because > it has to be a c-expr and that has no notion of atom vs. no-atom. "1" is a valid c-expr, and quite atomy :) (Or "true") > But the issue is to unambiguously parse the else clause, thus Ah, yes, I remember, the c-expr vs expr case; the parser is too limited :) In that case I find the extra keyword without parens even better: (switch when (bla) (foo) when (bar) (boo) (blob)) I.e. following 'when' it's an c-expr (when single token, parens optional), when not following 'when' its a result expr (atomic or not). Think of it as an infix multi-part keyword (like smalltalk has multi-part method names), the keyword(s) being "switch(when)*". I'm undecided if I'd allow function calls as atoms as well (because they contain parens), like so: (switch when integer_zero(@0) @1 when integer_zero(@1) @0 (plus @0 @1)) This would mean that there would be no single-token conditions without parens where one could leave out outer parens, as otherwise you have a ambiguity between: (switch when true (@0) // (@0) is the result ...) and (switch when token(@0) @1 // (@0) belongs to the when-expr ...) One has to chose between one or the other, and I think the latter (i.e. function calls as lone when-expr) occur more often. (Limiting the number of parens is worthwhile IMHO, but you probably guessed that much already :)) Ciao, Michael.