W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

[Bug 14188] Union types

From: <bugzilla@jessica.w3.org>
Date: Wed, 14 Dec 2011 04:08:25 +0000
To: public-script-coord@w3.org
Message-Id: <E1Rag8n-0002g2-Pc@jessica.w3.org>
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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC