union type syntax

Peter Hall peter.hall at memorphic.com
Sat Mar 22 03:54:01 PDT 2008

When programmers see a type union expression for the first time, and
are going to intuitively understand "|" to be an operator, which has a
new meaning when applied to types. Programmers routinely use parens
around complex expressions that involve multiple operators, for
readability and to ensure they didn't make a mistake around operator
precedence. But parens are never required in those places, and it
would add an odd asymmetry to the language to require them here.

I vote they are dropped unless there is a compelling technical reason,
related to machine parsing.


On Fri, Mar 21, 2008 at 10:46 PM, Waldemar Horwat <waldemar at google.com> wrote:
> There is no solid technical reason for requiring parentheses here.  They're here because of people's preferences.  I don't find them particularly useful here.
>     Waldemar
>  Peter Hall wrote:
>  > Now that union type uses "|" instead of "," for the delimiter, could
>  > the parentheses be made optional? It seems like parentheses are used
>  > elsewhere only for grouping and function calls/definitions.
>  >
>  >     UnionType ::=  Type ( "|" UnionType )?
>  >
>  > which should be easily distinguishable from a bitwise OR expression.

More information about the Es4-discuss mailing list