[Bug 15986] Specify exactly how and when ECMAScript arguments are evaluated

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

--- Comment #13 from Cameron McCormack <cam@mcc.id.au> 2012-02-20 02:02:25 UTC ---
(In reply to comment #12)
> I would personally be fine with that.  Can we survey existing usage of
> overloads in specs?

All the existing uses of overloads that I could find are below.  Many of them
can be be replaced with uses of optional and union types.  The ones that cannot
be rewritten to use only overloading with different argument list lengths
(where shorter ones are all prefixes of the longer ones) are
BlobBuilder.append, CanvasRenderingContext2D.createImageData and
DataTransferItemList.add.


File API:

  [Constructor,
   Constructor(any[] blobParts, optional BlobPropertyBag options)]
  interface Blob {
    ...
  };

File Writer:

  interface BlobBuilder {
    void append(in DOMString text, optional in DOMString endings);
    void append(in Blob data);
    void append(in ArrayBuffer data);
  };

HTML:

  interface HTMLOptionsCollection : HTMLCollection {
    void add(HTMLOptionElement element, optional HTMLElement? before);
    void add(HTMLOptGroupElement element, optional HTMLElement? before);
    void add(HTMLOptionElement element, long before);
    void add(HTMLOptGroupElement element, long before);
  };

  partial interface Document {
    Document open(optional DOMString type, optional DOMString replace);
    WindowProxy open(DOMString url, DOMString name, DOMString features,
                     optional boolean replace);

    boolean execCommand(DOMString commandId);
    boolean execCommand(DOMString commandId, boolean showUI);
    boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
  };

  [NamedConstructor=Image(),
   NamedConstructor=Image(unsigned long width),
   NamedConstructor=Image(unsigned long width, unsigned long height)]
  interface HTMLImageElement : HTMLElement {
    ...
  };

  [NamedConstructor=Audio(),
   NamedConstructor=Audio(DOMString src)]
  interface HTMLAudioElement : HTMLMediaElement {
  };

  interface CanvasRenderingContext2D {
    CanvasPattern createPattern(HTMLImageElement image, DOMString repetition);
    CanvasPattern createPattern(HTMLCanvasElement image, DOMString repetition);
    CanvasPattern createPattern(HTMLVideoElement image, DOMString repetition);

    void drawImage(HTMLImageElement image,
                   double dx, double dy);
    void drawImage(HTMLImageElement image,
                   double dx, double dy, double dw, double dh);
    void drawImage(HTMLImageElement image,
                   double sx, double sy, double sw, double sh,
                   double dx, double dy, double dw, double dh);
    void drawImage(HTMLCanvasElement image,
                   double dx, double dy);
    void drawImage(HTMLCanvasElement image,
                   double dx, double dy, double dw, double dh);
    void drawImage(HTMLCanvasElement image,
                   double sx, double sy, double sw, double sh,
                   double dx, double dy, double dw, double dh);
    void drawImage(HTMLVideoElement image,
                   double dx, double dy);
    void drawImage(HTMLVideoElement image,
                   double dx, double dy, double dw, double dh);
    void drawImage(HTMLVideoElement image,
                   double sx, double sy, double sw, double sh,
                   double dx, double dy, double dw, double dh);

    ImageData createImageData(double sw, double sh);
    ImageData createImageData(ImageData imagedata);

    void putImageData(ImageData imagedata, double dx, double dy);
    void putImageData(ImageData imagedata, double dx, double dy,
                      double dirtyX, double dirtyY,
                      double dirtyWidth, double dirtyHeight);
  };

  interface HTMLSelectElement : HTMLElement {
    void add(HTMLOptionElement element, optional HTMLElement? before);
    void add(HTMLOptGroupElement element, optional HTMLElement? before);
    void add(HTMLOptionElement element, long before);
    void add(HTMLOptGroupElement element, long before);
  };

  [NamedConstructor=Option(),
   NamedConstructor=Option(DOMString text),
   NamedConstructor=Option(DOMString text, DOMString value),
   NamedConstructor=Option(DOMString text, DOMString value,
                           boolean defaultSelected),
   NamedConstructor=Option(DOMString text, DOMString value,
                           boolean defaultSelected, boolean selected)]
  interface HTMLOptionElement : HTMLElement {
    ...
  };

  interface WindowTimers {
    long setTimeout(Function handler, optional long timeout, any... args);
    long setTimeout(DOMString handler, optional long timeout, any... args);

    long setInterval(Function handler, optional long timeout, any... args);
    long setInterval(DOMString handler, optional long timeout, any... args);
  };

  interface DataTransferItemList {
    DataTransferItem? add(DOMString data, DOMString type);
    DataTransferItem? add(File data);
  };

  [Constructor(DOMString url, optional DOMString protocols),
   Constructor(DOMString url, optional DOMString[] protocols)]
  interface WebSocket : EventTarget {
    ...
  };

XHR:

  interface XMLHttpRequest : XMLHttpRequestEventTarget {
    void send();
    void send(ArrayBuffer data);
    void send(Blob data);
    void send(Document data);
    void send(DOMString? data);
    void send(FormData data);
  };

-- 
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 Monday, 20 February 2012 02:02:29 UTC