Skip to content

Commit

Permalink
Don't treat explicit 'undefined' as a 'missing' argument value when p…
Browse files Browse the repository at this point in the history
…assed in variadic position.
  • Loading branch information
heycam committed Nov 6, 2013
1 parent 00ce09e commit ff92fdf
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 94 deletions.
74 changes: 41 additions & 33 deletions Overview.html
Expand Up @@ -11,7 +11,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Web IDL (Second Edition)</title>
<meta name="revision" content="$Id: Overview.html,v 1.689 2013-09-26 08:52:55 cmccorma Exp $" />
<meta name="revision" content="$Id: Overview.html,v 1.690 2013-09-27 04:34:45 cmccorma Exp $" />
<link rel="stylesheet" href="WebIDL.css" type="text/css" />
<script src="section-links.js" type="application/ecmascript"></script>
<script src="dfn.js" type="application/ecmascript"></script>
Expand All @@ -20,7 +20,7 @@
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-ED" type="text/css" /></head>

<body>
<div class="head"><div><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" width="72" height="48" alt="W3C" /></a></div><h1>Web IDL (Second Edition)</h1><h2>W3C Editor’s Draft <em>26 September 2013</em></h2><dl><dt>This Version:</dt><dd><a href="http://dev.w3.org/2006/webapi/WebIDL/">http://dev.w3.org/2006/webapi/WebIDL/</a></dd><dt>Latest Version:</dt><dd><a href="http://www.w3.org/TR/WebIDL/">http://www.w3.org/TR/WebIDL/</a></dd><dt>Previous Versions:</dt><dd><a href="http://www.w3.org/TR/2012/CR-WebIDL-20120419/">http://www.w3.org/TR/2012/CR-WebIDL-20120419/</a></dd><dd><a href="http://www.w3.org/TR/2012/WD-WebIDL-20120207/">http://www.w3.org/TR/2012/WD-WebIDL-20120207/</a></dd><dd><a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/">http://www.w3.org/TR/2011/WD-WebIDL-20110927/</a></dd><dd><a href="http://www.w3.org/TR/2011/WD-WebIDL-20110712/">http://www.w3.org/TR/2011/WD-WebIDL-20110712/</a></dd><dd><a href="http://www.w3.org/TR/2010/WD-WebIDL-20101021/">http://www.w3.org/TR/2010/WD-WebIDL-20101021/</a></dd><dd><a href="http://www.w3.org/TR/2008/WD-WebIDL-20081219/">http://www.w3.org/TR/2008/WD-WebIDL-20081219/</a></dd><dd><a href="http://www.w3.org/TR/2008/WD-WebIDL-20080829/">http://www.w3.org/TR/2008/WD-WebIDL-20080829/</a></dd><dd><a href="http://www.w3.org/TR/2008/WD-DOM-Bindings-20080410/">http://www.w3.org/TR/2008/WD-DOM-Bindings-20080410/</a></dd><dd><a href="http://www.w3.org/TR/2007/WD-DOM-Bindings-20071017/">http://www.w3.org/TR/2007/WD-DOM-Bindings-20071017/</a></dd><dt>Participate:</dt><dd>
<div class="head"><div><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" width="72" height="48" alt="W3C" /></a></div><h1>Web IDL (Second Edition)</h1><h2>W3C Editor’s Draft <em>27 September 2013</em></h2><dl><dt>This Version:</dt><dd><a href="http://dev.w3.org/2006/webapi/WebIDL/">http://dev.w3.org/2006/webapi/WebIDL/</a></dd><dt>Latest Version:</dt><dd><a href="http://www.w3.org/TR/WebIDL/">http://www.w3.org/TR/WebIDL/</a></dd><dt>Previous Versions:</dt><dd><a href="http://www.w3.org/TR/2012/CR-WebIDL-20120419/">http://www.w3.org/TR/2012/CR-WebIDL-20120419/</a></dd><dd><a href="http://www.w3.org/TR/2012/WD-WebIDL-20120207/">http://www.w3.org/TR/2012/WD-WebIDL-20120207/</a></dd><dd><a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/">http://www.w3.org/TR/2011/WD-WebIDL-20110927/</a></dd><dd><a href="http://www.w3.org/TR/2011/WD-WebIDL-20110712/">http://www.w3.org/TR/2011/WD-WebIDL-20110712/</a></dd><dd><a href="http://www.w3.org/TR/2010/WD-WebIDL-20101021/">http://www.w3.org/TR/2010/WD-WebIDL-20101021/</a></dd><dd><a href="http://www.w3.org/TR/2008/WD-WebIDL-20081219/">http://www.w3.org/TR/2008/WD-WebIDL-20081219/</a></dd><dd><a href="http://www.w3.org/TR/2008/WD-WebIDL-20080829/">http://www.w3.org/TR/2008/WD-WebIDL-20080829/</a></dd><dd><a href="http://www.w3.org/TR/2008/WD-DOM-Bindings-20080410/">http://www.w3.org/TR/2008/WD-DOM-Bindings-20080410/</a></dd><dd><a href="http://www.w3.org/TR/2007/WD-DOM-Bindings-20071017/">http://www.w3.org/TR/2007/WD-DOM-Bindings-20071017/</a></dd><dt>Participate:</dt><dd>
Send feedback to <a href="mailto:public-script-coord@w3.org">public-script-coord@w3.org</a> or <a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WebAppsWG&amp;component=WebIDL">file a bug</a> (<a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=WebAppsWG&amp;component=WebIDL&amp;resolution=---">open bugs</a>)
</dd><dt>Editor:</dt><dd><a href="http://mcc.id.au/">Cameron McCormack</a>, Mozilla Corporation &lt;cam@mcc.id.au&gt;</dd></dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> &copy; 2013 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>&reg;</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p></div><hr /><script async="" src="file-bug.js"></script>

Expand Down Expand Up @@ -73,7 +73,7 @@ <h2 id="sotd">Status of This Document</h2>
report can be found in the <a href="http://www.w3.org/TR/">W3C technical
reports index</a> at http://www.w3.org/TR/.
</em></p><p>
This document is the 26 September 2013 <b>Editor’s Draft</b> of the
This document is the 27 September 2013 <b>Editor’s Draft</b> of the
<cite>Web IDL (Second Edition)</cite> specification.

Please send comments about this document to
Expand Down Expand Up @@ -3106,13 +3106,15 @@ <h4>3.2.6. Overloading</h4>
</p>
<p>
The elements of an effective overload set are tuples of the form
&lt;<var>callable</var>, <var>type list</var>, <var>optional list</var>&gt;. If the effective overload
&lt;<var>callable</var>, <var>type list</var>, <var>optionality list</var>&gt;. If the effective overload
set is for regular operations, static operations or legacy callers, then <var>callable</var> is an operation;
if it is for constructors or named constructors, then <var>callable</var> is an
extended attribute; and if it is for callback functions, then <var>callable</var>
is the callback function itself. In all cases, <var>type list</var> is a list
of IDL types, and <var>optional list</var> is a list of booleans indicating whether
the argument at a given index was declared as being <a class="dfnref" href="#dfn-optional-argument">optional</a>.
of IDL types, and <var>optionality list</var> is a list of three possible <dfn id="dfn-optionality-value">optionality values</dfn> –
“required”, “optional” or “variadic” – indicating whether
the argument at a given index was declared as being <a class="dfnref" href="#dfn-optional-argument">optional</a>
or corresponds to a <a class="dfnref" href="#dfn-variadic">variadic</a> argument.
Each tuple represents an allowable invocation of the operation,
constructor, legacy caller or callback function with an argument value list of the given types.
Due to the use of <a class="dfnref" href="#dfn-optional-argument">optional arguments</a>
Expand Down Expand Up @@ -3213,20 +3215,22 @@ <h4>3.2.6. Overloading</h4>
<li>Let <var>n</var> be the number of arguments <var>X</var> is declared to take.</li>
<li>Let <var>t</var><sub>0..<var>n</var>−1</sub> be a list of types, where <var>t</var><sub><var>i</var></sub>
is the type of <var>X</var>’s argument at index <var>i</var>.</li>
<li>Let <var>o</var><sub>0..<var>n</var>−1</sub> be a list of booleans, where <var>o</var><sub><var>i</var></sub>
is true if <var>X</var>’s argument at index <var>i</var> is optional, and false otherwise.</li>
<li>Let <var>o</var><sub>0..<var>n</var>−1</sub> be a list of <a class="dfnref" href="#dfn-optionality-value">optionality values</a>, where <var>o</var><sub><var>i</var></sub>
is “variadic” if <var>X</var>’s argument at index <var>i</var> is a final, variadic argument,
“optional” if the argument is <a class="dfnref" href="#dfn-optional-argument">optional</a>,
and “required” otherwise.</li>
<li>Add to <var>S</var> the tuple &lt;<var>X</var>, <var>t</var><sub>0..<var>n</var>−1</sub>, <var>o</var><sub>0..<var>n</var>−1</sub>&gt;.</li>
<li>If <var>n</var> &gt; 0 and <var>X</var> is declared to be <a class="dfnref" href="#dfn-variadic">variadic</a>, then:
<li>If <var>X</var> is declared to be <a class="dfnref" href="#dfn-variadic">variadic</a>, then:
<ol>
<li>Add to <var>S</var> the tuple &lt;<var>X</var>, <var>t</var><sub>0..<var>n</var>−2</sub>, <var>o</var><sub>0..<var>n</var>−2</sub>&gt;.
<div class="note"><div class="noteHeader">Note</div>
<p>This leaves off the final, varidiac argument.</p>
<p>This leaves off the final, variadic argument.</p>
</div>
</li>
<li>For every integer <var>i</var>, such that <var>n</var> ≤ <var>i</var> ≤ <var>m</var>−1:
<ol>
<li>Let <var>u</var><sub>0..<var>i</var></sub> be a list of types, where <var>u</var><sub>j</sub> = <var>t</var><sub>j</sub> (for <var>j</var> &lt; <var>n</var>) and <var>u</var><sub>j</sub> = <var>t</var><sub><var>n</var>−1</sub> (for <var>j</var> ≥ <var>n</var>).</li>
<li>Let <var>p</var><sub>0..<var>i</var></sub> be a list of booleans, where <var>p</var><sub>j</sub> = <var>o</var><sub>j</sub> (for <var>j</var> &lt; <var>n</var>) and <var>p</var><sub>j</sub> = true (for <var>j</var> ≥ <var>n</var>).</li>
<li>Let <var>p</var><sub>0..<var>i</var></sub> be a list of <a class="dfnref" href="#dfn-optionality-value">optionality values</a>, where <var>p</var><sub>j</sub> = <var>o</var><sub>j</sub> (for <var>j</var> &lt; <var>n</var>) and <var>p</var><sub>j</sub> = “variadic” (for <var>j</var> ≥ <var>n</var>).</li>
<li>Add to <var>S</var> the tuple &lt;<var>X</var>, <var>u</var><sub>0..<var>i</var></sub>, <var>p</var><sub>0..<var>i</var></sub>&gt;.</li>
</ol>
</li>
Expand Down Expand Up @@ -3265,14 +3269,14 @@ <h4>3.2.6. Overloading</h4>
identifier <code>f</code> and argument count 4 is:
</p>
<div class="set">
{ &lt;f1, (DOMString), (false)&gt;,<br />
&lt;f2, (Node, DOMString), (false, false)&gt;,<br />
&lt;f2, (Node, DOMString, float), (false, false, true)&gt;,<br />
&lt;f2, (Node, DOMString, float, float), (false, false, true, true)&gt;,<br />
{ &lt;f1, (DOMString), (required)&gt;,<br />
&lt;f2, (Node, DOMString), (required, required)&gt;,<br />
&lt;f2, (Node, DOMString, float), (required, required, variadic)&gt;,<br />
&lt;f2, (Node, DOMString, float, float), (required, required, variadic, variadic)&gt;,<br />
&lt;f3, (), ()&gt;,<br />
&lt;f4, (Event, DOMString), (false, false)&gt;,<br />
&lt;f4, (Event, DOMString, DOMString), (false, false, true)&gt;,<br />
&lt;f4, (Event, DOMString, DOMString, float), (false, false, true, true)&gt; }
&lt;f4, (Event, DOMString), (required, required)&gt;,<br />
&lt;f4, (Event, DOMString, DOMString), (required, required, optional)&gt;,<br />
&lt;f4, (Event, DOMString, DOMString, float), (required, required, optional, variadic)&gt; }
</div>
</div>
<!--
Expand Down Expand Up @@ -3605,9 +3609,9 @@ <h4>3.2.6. Overloading</h4>
For argument count 4, the effective overload set is:
</p>
<div class="set">
{ &lt;f1, (DOMString), (false)&gt;,<br />
&lt;f2, (long, float, Node, Node), (false, false, false, false)&gt;,<br />
&lt;f3, (float, float, DOMString, Node), (false, false, false, false)&gt; }
{ &lt;f1, (DOMString), (required)&gt;,<br />
&lt;f2, (long, float, Node, Node), (required, required, required, required)&gt;,<br />
&lt;f3, (float, float, DOMString, Node), (required, required, required, required)&gt; }
</div>
<p>
Looking at entries with type list length 4, the
Expand Down Expand Up @@ -10356,10 +10360,10 @@ <h5>4.5.1.1. Interface object [[Call]] method</h5>
<ol>
<li>Let <var>V</var> be <var>arg</var><sub><var>i</var></sub>.</li>
<li>Let <var>type</var> be the type at index <var>i</var> in the type list of any entry in <var>S</var>.
<div class="note"><div class="noteHeader">Note</div><p>All entries in <var>S</var> at this point have the same type and boolean value (indicating argument optionality) at index <var>i</var>.</p></div>
<div class="note"><div class="noteHeader">Note</div><p>All entries in <var>S</var> at this point have the same type and <a class="dfnref" href="#dfn-optionality-value">optionality value</a> at index <var>i</var>.</p></div>
</li>
<li>Let <var>optional</var> be the boolean at index <var>i</var> in the list of booleans of any entry in <var>S</var>.</li>
<li>If <var>optional</var> is true and <var>V</var> is <span class="esvalue">undefined</span>, then:
<li>Let <var>optionality</var> be the value at index <var>i</var> in the list of <a class="dfnref" href="#dfn-optionality-value">optionality values</a> of any entry in <var>S</var>.</li>
<li>If <var>optionality</var> is “optional” and <var>V</var> is <span class="esvalue">undefined</span>, then:
<ol>
<li>If the argument at index <var>i</var> is declared with a <a class="dfnref" href="#dfn-optional-argument-default-value">default value</a>,
then append to <var>values</var> that default value.</li>
Expand All @@ -10378,10 +10382,10 @@ <h5>4.5.1.1. Interface object [[Call]] method</h5>
<div class="note"><div class="noteHeader">Note</div><p>This is the argument that will be used to resolve which overload is selected.</p></div></li>

<li>If <var>V</var> is <span class="esvalue">undefined</span>, and there is an entry in <var>S</var>
whose list of booleans indicating argument optionality is true at index <var>i</var>,
whose list of <a class="dfnref" href="#dfn-optionality-value">optionality values</a> has “optional” at index <var>i</var>,
then remove from <var>S</var> all other entries.</li>

<li>Otherwise, if <var>V</var> is <span class="esvalue">null</span> or <span class="esvalue">undefined</span>,
<li>Otherwise: if <var>V</var> is <span class="esvalue">null</span> or <span class="esvalue">undefined</span>,
and there is an entry in <var>S</var> that has one of the following types at position <var>i</var> of its type list,
<ul>
<li>a <a class="dfnref" href="#dfn-nullable-type">nullable type</a></li>
Expand Down Expand Up @@ -10542,18 +10546,18 @@ <h5>4.5.1.1. Interface object [[Call]] method</h5>
<li>
While <var>i</var> &lt; <var>argcount</var>:
<ol>
<li>Let <var>V</var> be <var>arg</var><sub><var>i</var></sub>.</li>
<li>Let <var>type</var> be the type at index <var>i</var> in the type list of the remaining entry in <var>S</var>.</li>
<li>Let <var>optional</var> be the boolean at index <var>i</var> in the list of booleans of the remaining entry in <var>S</var>.</li>
<li>If <var>optional</var> is true and <var>V</var> is <span class="esvalue">undefined</span>, then:
<li>Let <var>optionality</var> be the value at index <var>i</var> in the list of <a class="dfnref" href="#dfn-optionality-value">optionality values</a> of the remaining entry in <var>S</var>.</li>
<li>If <var>optionality</var> is “optional” and <var>V</var> is <span class="esvalue">undefined</span>, then:
<ol>
<li>If <var>i</var> is less than the number of arguments <var>callable</var> is declared to take,
and the argument at index <var>i</var> is declared with a <a class="dfnref" href="#dfn-optional-argument-default-value">default value</a>,
<li>If the argument at index <var>i</var> is declared with a <a class="dfnref" href="#dfn-optional-argument-default-value">default value</a>,
then append to <var>values</var> that default value.</li>
<li>Otherwise, append to <var>values</var> the special value “missing”.</li>
</ol>
</li>
<li>Otherwise, append to <var>values</var> the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>V</var> to IDL type <var>type</var>.</li>
<li>Otherwise, append to <var>values</var> the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a> <var>V</var> to IDL type <var>type</var>.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
Expand All @@ -10562,7 +10566,7 @@ <h5>4.5.1.1. Interface object [[Call]] method</h5>
<ol>
<li>If <var>callable</var>’s argument at index <var>i</var> is declared with a <a class="dfnref" href="#dfn-optional-argument-default-value">default value</a>,
then append to <var>values</var> that default value.</li>
<li>Otherwise, append to <var>values</var> the special value “missing”.</li>
<li>Otherwise, if <var>callable</var>’s argument at index <var>i</var> is not variadic, then append to <var>values</var> the special value “missing”.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
Expand Down Expand Up @@ -10616,6 +10620,10 @@ <h5>4.5.1.1. Interface object [[Call]] method</h5>
<span class="esvalue">undefined</span> will be converted into
the <a class="dfnref" href="#dfn-optional-argument-default-value">optional argument’s default value</a>,
if it has one, or a special value “missing” otherwise.</p>
<p>Optional arguments corresponding to a final, variadic argument do not treat
<span class="esvalue">undefined</span> as a special “missing” value, however.
The <span class="esvalue">undefined</span> value is converted to the type
of variadic argument as would be done for a non-optional argument.</p>
</div>
<p>
The internal <span class="prop">[[Call]]</span> method
Expand Down

0 comments on commit ff92fdf

Please sign in to comment.