[Bug 14188] Union types

https://www.w3.org/Bugs/Public/show_bug.cgi?id=14188

--- Comment #7 from Cameron McCormack <cam@mcc.id.au> 2011-12-14 04:08:24 UTC ---
Union types are not necessary for some simple overloading cases, like the
various canvas methods

  void drawImage(HTMLCanvasElement e, float x, float y);
  void drawImage(HTMLImageElement e, float x, float y);

although they would probably benefit from becoming more readable.

They are necessary for the case that Anne brings up there, specifying the type
of the variadic arguments in an operation (unless you want to use "any"). 
Similarly for the element type of sequence<T> and T[].

But union types bring with them the same kinds of problems that overloading
does, namely how to select which of the constituent types is meant when you
need to convert values.

  void f(Node or DOMString x);

Do ToObject and check if it's a Node, or do a ToString and assume it's a
DOMString?

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Wednesday, 14 December 2011 04:08:27 UTC