union type syntax

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

union type syntax

Peter Hall-4
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.


Peter
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

RE: union type syntax

Lars Hansen-3
The parens are required.  Long discussion here:
http://bugs.ecmascript.org/ticket/308
 
--lars

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Peter Hall
> Sent: 18. mars 2008 09:58
> To: [hidden email] es4-discuss
> Subject: union type syntax
>
> 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.
>
>
> Peter
> _______________________________________________
> Es4-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es4-discuss
>
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: union type syntax

Waldemar Horwat
In reply to this post by Peter Hall-4
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.
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: union type syntax

Peter Hall-4
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.


Peter

On Fri, Mar 21, 2008 at 10:46 PM, Waldemar Horwat <[hidden email]> 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.
>
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss