Syntax for union types
Brendan Eich
brendan at mozilla.org
Fri Nov 9 10:21:50 PST 2007
As Lars suggested, we have bigger fish to fry, but we settled on
union syntax quickly and were content to stay there. I'm not against
| instead of , and if enough people think it's the right user
interface, we could consider it again. I'm not saying it's a good use
of time to fuss over this, but it's "fixable" if (T, U, ...) is not
as good as (T | U | ...).
Recall that ES4 and indeed JavaScript do not have tuples, so we want
to use [T, U] for the array structural type describing a tuple of at
least index 0 of type T and index 1 of type U. If we ever did add
tuples, then Yuh-Ruey has a point I think: we might rather use (T |
U) for union of T and U, and (T, U) -- or possibly (T, U,) to match
expression syntax (which would have to be (e1, e2,) to avoid
ambiguity with comma expression) for tuple type.
/be
More information about the Es4-discuss
mailing list