Syntax for union types

Jason Orendorff jason.orendorff at gmail.com
Mon Oct 29 08:56:07 PDT 2007


On Oct 26, 2007 6:35 PM, James Clark <jjc at jclark.com> wrote:
> (int, string) doesn't seem to me to be a syntax that the average JS
> programmer will guess means union. I would have thought a better choice
> would be (int | string) (especially given that regexps use |) or a keyword.

Yep.  I read (int, string) as a tuple type every time.  ML, Haskell,
Python 3.0... I'm not sure what we gain by going against the grain
here.

So it's not a big deal, but switching to (t1 | t2) seems all upside to
me.  It's a shallow change.  +1.

-j



More information about the Es4-discuss mailing list