From 5ee55c8f14b36efc06a63e8b1f4f2fcb315282a7 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Wed, 16 Aug 2017 22:39:26 +0800 Subject: [PATCH] Remove legacy callers Turns out there is only one interface in the Platform using legacy callers (HTMLAllCollection). Define the exotic behaviors there instead. Fixes #407. Fixes #408. --- index.bs | 127 ++++--------------------------------------------------- 1 file changed, 8 insertions(+), 119 deletions(-) diff --git a/index.bs b/index.bs index 63b18cae..66a0fd43 100644 --- a/index.bs +++ b/index.bs @@ -568,7 +568,6 @@ underscore. "inherit" "interface" "iterable" - "legacycaller" "maplike" "namespace" "partial" @@ -1950,7 +1949,6 @@ The following extended attributes are applicable to operations: "getter" "setter" "deleter" - "legacycaller"
@@ -2141,11 +2139,6 @@ is used to declare it and what the purpose of the special operation is:
         deleter
         Defines behavior for when an object is indexed for property deletion.
     
-    
-        Legacy callers
-        legacycaller
-        Defines behavior for when an object is called as if it were a function.
-    
     
         Stringifiers
         stringifier
@@ -2231,8 +2224,6 @@ there must exist at most one
 stringifier, at most one
 [=named property deleter=],
 and at most one of each variety of getter and setter.
-Multiple legacy callers can exist on an interface
-to specify overloaded calling behavior.
 
 If an interface has a setter of a given variety,
 then it must also have a getter of that
@@ -2252,73 +2243,6 @@ that defines a given special operation, then it is undefined which (if any)
 special operation is invoked for that operation.
 
 
-
Legacy callers
- -When an [=interface=] has one or more -[=legacy callers=], it indicates that objects that implement -the interface can be called as if they were functions. As mentioned above, -legacy callers can be specified using an [=operation=] -declared with the legacycaller keyword. - -
-    interface interface_identifier {
-      legacycaller return_type identifier(/* arguments... */);
-      legacycaller return_type (/* arguments... */);
-    };
-
- -If multiple legacy callers are specified on an interface, overload resolution -is used to determine which legacy caller is invoked when the object is called -as if it were a function. - -[=Legacy callers=] can only be defined on interfaces that also -[=support indexed properties|support indexed=] or -[=support named properties|named properties=]. - -Note: This artificial restriction allows bundling all interfaces with exotic object behavior -into a single [=platform object=] category: [=legacy platform objects=]. -This is possible because all existing interfaces which have a [=legacy caller=] -also [=support indexed properties|supports indexed=] or -[=support named properties|named properties=]. - -Legacy callers must not be defined to return a [=promise type=]. - -

- Legacy callers are universally recognised as an undesirable feature. They exist - only so that legacy Web platform features can be specified. Legacy callers - should not be used in specifications unless required to - specify the behavior of legacy APIs, and even then this should be discussed on - the public-script-coord@w3.org - mailing list before proceeding. -

- -
- - The following [=IDL fragment=] - defines an [=interface=] - with a [=legacy caller=]. - -
-        interface NumberQuadrupler {
-          // This operation simply returns four times the given number x.
-          legacycaller double compute(double x);
-        };
-    
- - An ECMAScript implementation supporting this interface would - allow a [=platform object=] - that implements NumberQuadrupler - to be called as a function: - -
-        var f = getNumberQuadrupler();  // Obtain an instance of NumberQuadrupler.
-
-        f.compute(3);                   // This evaluates to 12.
-        f(3);                           // This also evaluates to 12.
-    
-
- -
Stringifiers
When an [=interface=] has a @@ -2797,17 +2721,13 @@ of an overloaded operation is used to invoke one of the operations on an object that implements the interface, the number and types of the arguments passed to the operation determine which of the overloaded operations is actually -invoked. If an interface has multiple -[=legacy callers=] defined on it, -then those legacy callers are also said to be overloaded. -In the ECMAScript language binding, constructors +invoked. In the ECMAScript language binding, constructors can be overloaded too. There are some restrictions on the arguments -that overloaded operations, legacy callers and constructors can be +that overloaded operations and constructors can be specified to take, and in order to describe these restrictions, the notion of an effective overload set is used. -[=Operations=] and [=legacy callers=] -must not be overloaded across [=interface=] +[=Operations=] must not be overloaded across [=interface=] and [=partial interface=] definitions.
@@ -2842,8 +2762,7 @@ An effective overload set represents the allowable invocations for a particular [=operation=], constructor (specified with [{{Constructor}}] -or [{{NamedConstructor}}]), -[=legacy caller=] or +or [{{NamedConstructor}}]), or [=callback function=]. The algorithm to compute an [=effective overload set=] operates on one of the following six types of IDL constructs, and listed with them below are @@ -2854,9 +2773,6 @@ the inputs to the algorithm needed to compute the set. :: * the [=interface=] on which the [=operations=] are to be found * the [=identifier=] of the operations * the number of arguments to be passed - : For legacy callers - :: * the [=interface=] on which the [=legacy callers=] are to be found - * the number of arguments to be passed : For constructors :: * the [=interface=] on which the [{{Constructor}}] [=extended attributes=] are to be found * the number of arguments to be passed @@ -2869,14 +2785,14 @@ the inputs to the algorithm needed to compute the set. * the number of arguments to be passed An effective overload set is used, among other things, to determine whether there are ambiguities in the -overloaded operations, constructors and callers specified on an interface. +overloaded operations and constructors specified on an interface. The [=set/items=] of an [=effective overload set=] are [=tuples=] of the form ([=effective overload set tuple/callable=], [=type list=], [=optionality list=]) whose [=tuple/items=] are described below: * A callable is an [=operation=] - if the [=effective overload set=] is for [=regular operations=], [=static operations=] or [=legacy callers=]; + if the [=effective overload set=] is for [=regular operations=] or [=static operations=]; it is an [=extended attribute=] if the [=effective overload set=] is for constructors or [=named constructors=]; and it is the [=callback function=] itself if the [=effective overload set=] is for [=callback functions=]. * A type list is a [=list=] of IDL types. @@ -2888,7 +2804,7 @@ whose [=tuple/items=] are described below: or corresponds to a [=variadic=] 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. +constructor, or callback function with an argument value list of the given types. Due to the use of [=optional arguments=] and [=variadic=] operations and constructors, there may be multiple items in an effective overload set identifying @@ -2927,9 +2843,6 @@ the same operation or constructor. [=extended attributes=] on interface |I| whose [=takes a named argument list|named argument lists’=] identifiers are |A|. - : For legacy callers - :: The elements of |F| are the [=legacy callers=] - defined on interface |I|. : For callback functions :: The single element of |F| is the callback function itself, |C|. @@ -4815,8 +4728,7 @@ object that are considered to be platform objects: [=platform objects=] that implement an [=interface=] which does not have a [{{Global}}] or [{{PrimaryGlobal}}] [=extended attribute=], [=support indexed properties|supports indexed=] or -[=support named properties|named properties=], -and may have one or multiple [=legacy callers=]. +[=support named properties|named properties=]. In a browser, for example, the browser-implemented DOM objects (implementing interfaces such as Node and @@ -12158,29 +12070,6 @@ and [[#legacy-platform-object-set]].
-

\[[Call]]

- -
- - The internal \[[Call]] method of [=legacy platform object=] that implements - an [=interface=] |I| must behave as follows, - assuming |arg|0..|n|−1 is the list of argument values passed to \[[Call]]: - - 1. If |I| has no [=legacy callers=], - [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. - 1. Initialize |S| to the [=effective overload set=] - for legacy callers on |I| and with argument count |n|. - 1. Let <|operation|, |values|> be the result of passing |S| and - |arg|0..|n|−1 to the [=overload resolution algorithm=]. - 1. Perform the actions listed in the description of the legacy caller |operation| with - |values| as the argument values. - 1. Return the result of [=converted to an ECMAScript value|converting=] - the return value from those actions to an ECMAScript value of the type - |operation| is declared to return (or undefined - if |operation| is declared to return {{void}}). -
- -

\[[PreventExtensions]]