diff --git a/index.bs b/index.bs index 10ae68ef..5a7bf417 100644 --- a/index.bs +++ b/index.bs @@ -705,7 +705,6 @@ underscore. "static" "stringifier" "typedef" - "unrestricted" If an identifier token is used, then the @@ -1699,12 +1698,12 @@ lie outside the valid range of values for its type, as given in 1. Let |result| be the Mathematical Value that would be obtained if |S| were parsed as an ECMAScript [=NumericLiteral=]. 1. If the decimal token is being - used as the value for a {{float}} or {{unrestricted float}}, then - the value of the decimal token + used as the value for a {{float}}, then the value of the + decimal token is the IEEE 754 single-precision floating point number closest to |result|. 1. Otherwise, the decimal token is being - used as the value for a {{double}} or {{unrestricted double}}, and - the value of the decimal token + used as the value for a {{double}}, then the value of the + decimal token is the IEEE 754 double-precision floating point number closest to |result|. [[!IEEE-754]] @@ -1716,17 +1715,17 @@ constant, dictionary member or optional argument is is being used as the value for:
- : Type {{unrestricted float}}, constant value Infinity + : Type [{{Unrestricted}}] {{float}}, constant value Infinity :: The value is the IEEE 754 single-precision positive infinity value. - : Type {{unrestricted double}}, constant value Infinity + : Type [{{Unrestricted}}] {{double}}, constant value Infinity :: The value is the IEEE 754 double-precision positive infinity value. - : Type {{unrestricted float}}, constant value -Infinity + : Type [{{Unrestricted}}] {{float}}, constant value -Infinity :: The value is the IEEE 754 single-precision negative infinity value. - : Type {{unrestricted double}}, constant value -Infinity + : Type [{{Unrestricted}}] {{double}}, constant value -Infinity :: The value is the IEEE 754 double-precision negative infinity value. - : Type {{unrestricted float}}, constant value NaN + : Type [{{Unrestricted}}] {{float}}, constant value NaN :: The value is the IEEE 754 single-precision NaN value with the bit pattern 0x7fc00000. - : Type {{unrestricted double}}, constant value NaN + : Type [{{Unrestricted}}] {{double}}, constant value NaN :: The value is the IEEE 754 double-precision NaN value with the bit pattern 0x7ff8000000000000.
@@ -5728,12 +5727,13 @@ The following types are known as integer types {{long long}} and {{unsigned long long}}. +The following types are known as float types: +{{float}} and +{{double}}. + The following types are known as numeric types: -the [=integer types=], -{{float}}, -{{unrestricted float}}, -{{double}} and -{{unrestricted double}}. +the [=integer types=], and +the [=float types=]. The primitive types are {{bigint}}, {{boolean}} and the [=numeric types=]. @@ -5837,7 +5837,7 @@ type.
     PrimitiveType :
         UnsignedIntegerType
-        UnrestrictedFloatType
+        FloatType
         "undefined"
         "boolean"
         "byte"
@@ -5845,13 +5845,7 @@ type.
         "bigint"
 
-
-    UnrestrictedFloatType :
-        "unrestricted" FloatType
-        FloatType
-
- -
+
     FloatType :
         "float"
         "double"
@@ -6061,6 +6055,10 @@ The {{float}} type is a floating point numeric
 type that corresponds to the set of finite single-precision 32 bit
 IEEE 754 floating point numbers. [[!IEEE-754]]
 
+When defined with the [{{Unrestricted}}] [=extended attribute=], the {{float}} type
+additionally corresponds to the single-precision 32 bit IEEE 754 non-finite,
+and special "not a number" values (NaNs). [[!IEEE-754]]
+
 {{float}} constant values in IDL are
 represented with decimal
 tokens.
@@ -6077,26 +6075,16 @@ The [=type name=] of the
 

-

unrestricted float

- -The {{unrestricted float}} type is a floating point numeric -type that corresponds to the set of all possible single-precision 32 bit -IEEE 754 floating point numbers, finite, non-finite, and special "not a number" values (NaNs). [[!IEEE-754]] - -{{unrestricted float}} constant values in IDL are -represented with decimal -tokens. - -The [=type name=] of the -{{unrestricted float}} type is "UnrestrictedFloat". - -

double

The {{double}} type is a floating point numeric type that corresponds to the set of finite double-precision 64 bit IEEE 754 floating point numbers. [[!IEEE-754]] +When defined with the [{{Unrestricted}}] [=extended attribute=], the {{double}} type +additionally corresponds to the double-precision 64 bit IEEE 754 non-finite, +and special "not a number" values (NaNs). [[!IEEE-754]] + {{double}} constant values in IDL are represented with decimal tokens. @@ -6105,20 +6093,6 @@ The [=type name=] of the {{double}} type is "Double". -

unrestricted double

- -The {{unrestricted double}} type is a floating point numeric -type that corresponds to the set of all possible double-precision 64 bit -IEEE 754 floating point numbers, finite, non-finite, and special "not a number" values (NaNs). [[!IEEE-754]] - -{{unrestricted double}} constant values in IDL are -represented with decimal -tokens. - -The [=type name=] of the -{{unrestricted double}} type is "UnrestrictedDouble". - -

bigint

The {{bigint}} type is an arbitrary integer type, unrestricted in range. @@ -6636,8 +6610,9 @@ annotate are called inner type The following extended attributes are applicable to types: [{{AllowShared}}], [{{Clamp}}], -[{{EnforceRange}}], and -[{{LegacyNullToEmptyString}}]. +[{{EnforceRange}}], +[{{LegacyNullToEmptyString}}], and +[{{Unrestricted}}].
The extended attributes associated with @@ -7384,8 +7359,9 @@ ECMAScript value type. 1. If Type(|V|) is Boolean, then return the {{boolean}} value that represents the same truth value. 1. If Type(|V|) is Number, then - return the result of converting |V| - to an {{unrestricted double}}. + return the result of converting |V| + to a {{double}} [=extended attribute associated with|with an associated=] + [{{Unrestricted}}] [=extended attribute=]. 1. If Type(|V|) is BigInt, then return the result of converting |V| to a {{bigint}}. @@ -7690,15 +7666,20 @@ In effect, where x is a Number value,
-

float

+

float

-
+
An ECMAScript value |V| is [=converted to an IDL value|converted=] to an IDL {{float}} value by running the following algorithm: 1. Let |x| be [=?=] ToNumber(|V|). - 1. If |x| is NaN, +∞, or −∞, + 1. If the conversion is to an IDL type [=extended attribute associated with|with an associated=] + [{{Unrestricted}}] [=extended attribute=], then: + 1. If |x| is NaN, then + return the IDL {{float}} value that represents + the IEEE 754 NaN value with the bit pattern 0x7fc00000 [[!IEEE-754]]. + 1. Else, if |x| is NaN, +∞, or −∞, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. 1. Let |S| be the set of finite IEEE 754 single-precision floating point values except −0, but with two special values added: 2128 and @@ -7708,38 +7689,11 @@ In effect, where x is a Number value, even significand if there are two [=equally close values=]. (The two special values 2128 and −2128 are considered to have even significands for this purpose.) - 1. If |y| is 2128 or −2128, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. - 1. If |y| is +0 and |x| is negative, return −0. - 1. Return |y|. -
- -

- The result of [=converted to an ECMAScript value|converting=] - an IDL {{float}} value to an ECMAScript - value is the Number value that represents the same numeric value as the IDL - {{float}} value. -

- - -

unrestricted float

- -
- - An ECMAScript value |V| is [=converted to an IDL value|converted=] - to an IDL {{unrestricted float}} value by running the following algorithm: - - 1. Let |x| be [=?=] ToNumber(|V|). - 1. If |x| is NaN, then return the IDL {{unrestricted float}} value that represents the IEEE 754 NaN value with the bit pattern 0x7fc00000 [[!IEEE-754]]. - 1. Let |S| be the set of finite IEEE 754 single-precision floating - point values except −0, but with two special values added: 2128 and - −2128. - 1. Let |y| be the number in |S| that is closest - to |x|, selecting the number with an - even significand if there are two [=equally close values=]. - (The two special values 2128 and −2128 - are considered to have even significands for this purpose.) - 1. If |y| is 2128, return +∞. - 1. If |y| is −2128, return −∞. + 1. If the conversion is to an IDL type [=extended attribute associated with|with an associated=] + [{{Unrestricted}}] [=extended attribute=], then: + 1. If |y| is 2128, return +∞. + 1. If |y| is −2128, return −∞. + 1. Else, if |y| is 2128 or −2128, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. 1. If |y| is +0 and |x| is negative, return −0. 1. Return |y|.
@@ -7749,73 +7703,59 @@ it must be canonicalized to a particular single precision IEEE 754 NaN value. T mentioned above is chosen simply because it is the quiet NaN with the lowest value when its bit pattern is interpreted as an unsigned 32 bit integer. -
- +
The result of [=converted to an ECMAScript value|converting=] - an IDL {{unrestricted float}} value to an ECMAScript + an IDL {{float}} value to an ECMAScript value is a Number: - 1. If the IDL {{unrestricted float}} value is a NaN, - then the Number value is NaN. - 1. Otherwise, the Number value is + 1. If the conversion is from an IDL type [=extended attribute associated with|with an associated=] + [{{Unrestricted}}] [=extended attribute=], then: + 1. If the IDL {{float}} value is a NaN, + then the Number value is NaN. + 1. Else, assert: The IDL {{float}} value is not a NaN, +∞ or −∞. + 1. The Number value is the one that represents the same numeric value as the IDL - {{unrestricted float}} value. + {{float}} value.
-

double

+

double

-
+
An ECMAScript value |V| is [=converted to an IDL value|converted=] to an IDL {{double}} value by running the following algorithm: 1. Let |x| be [=?=] ToNumber(|V|). - 1. If |x| is NaN, +∞, or −∞, + 1. If the conversion is to an IDL type [=extended attribute associated with|with an associated=] + [{{Unrestricted}}] [=extended attribute=], then: + 1. If |x| is NaN, then + return the IDL {{double}} value that represents + the IEEE 754 NaN value with the bit pattern 0x7ff8000000000000 [[!IEEE-754]]. + 1. Else, if |x| is NaN, +∞, or −∞, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. 1. Return the IDL {{double}} value that represents the same numeric value as |x|.
-

- The result of [=converted to an ECMAScript value|converting=] - an IDL {{double}} value to an ECMAScript - value is the Number value that represents the - same numeric value as the IDL {{double}} value. -

- - -

unrestricted double

- -
- - An ECMAScript value |V| is [=converted to an IDL value|converted=] - to an IDL {{unrestricted double}} value by running the following algorithm: - - 1. Let |x| be [=?=] ToNumber(|V|). - 1. If |x| is NaN, then - return the IDL {{unrestricted double}} value that represents - the IEEE 754 NaN value with the bit pattern 0x7ff8000000000000 [[!IEEE-754]]. - 1. Return the IDL {{unrestricted double}} value - that represents the same numeric value as |x|. -
- Note: Since there is only a single ECMAScript NaN value, it must be canonicalized to a particular double precision IEEE 754 NaN value. The NaN value mentioned above is chosen simply because it is the quiet NaN with the lowest value when its bit pattern is interpreted as an unsigned 64 bit integer. -
- +
The result of [=converted to an ECMAScript value|converting=] - an IDL {{unrestricted double}} value to an ECMAScript + an IDL {{double}} value to an ECMAScript value is a Number: - 1. If the IDL {{unrestricted double}} value is a NaN, - then the Number value is NaN. - 1. Otherwise, the Number value is + 1. If the conversion is from an IDL type [=extended attribute associated with|with an associated=] + [{{Unrestricted}}] [=extended attribute=], then: + 1. If the IDL {{double}} value is a NaN, + then the Number value is NaN. + 1. Else, assert: The IDL {{double}} value is not a NaN, +∞ or −∞. + 1. The Number value is the one that represents the same numeric value as the IDL - {{unrestricted double}} value. + {{double}} value.

bigint

@@ -8619,7 +8559,7 @@ JavaScript code.
         interface I {
-          Promise<undefined> delay(unrestricted double ms);
+          Promise<undefined> delay([Unrestricted] double ms);
         };
     
@@ -8647,7 +8587,7 @@ JavaScript code.
         interface I {
-          Promise<undefined> validatedDelay(unrestricted double ms);
+          Promise<undefined> validatedDelay([Unrestricted] double ms);
         };
     
@@ -8674,7 +8614,7 @@ JavaScript code.
         interface I {
-          Promise<any> addDelay(Promise<any> promise, unrestricted double ms);
+          Promise<any> addDelay(Promise<any> promise, [Unrestricted] double ms);
         };
     
@@ -10180,6 +10120,64 @@ that does specify [{{SecureContext}}].
+

[Unrestricted]

+ +If the [{{Unrestricted}}] [=extended attribute=] appears on one of the [=float types=], +it creates a new IDL type such that that when an ECMAScript Number is converted to the IDL type, +IEEE 754 non-finite, and special "not a number" values (NaNs) are allowed. [[!IEEE-754]] + +The [{{Unrestricted}}] +extended attribute must +[=takes no arguments|take no arguments=]. + +A type that is not a [=float type=] must not +be [=extended attributes associated with|associated with=] +the [{{Unrestricted}}] extended attribute. + +See the rules for converting ECMAScript values to the various IDL float types +in [[#es-float]] and [[#es-double]] +for the specific requirements that the use of +[{{Unrestricted}}] entails. + +
+ + In the following [=IDL fragment=], + two [=operations=] are declared that + take three {{double}} arguments; one uses + the [{{Unrestricted}}] [=extended attribute=] + on all three arguments, while the other does not: + +
+        [Exposed=Window]
+        interface GraphicsContext {
+          void setColorDouble(double red, double green, double blue);
+          void setColorUnrestrictedDouble([Unrestricted] double red, [Unrestricted] double green, [Unrestricted] double blue);
+        };
+    
+ + In an ECMAScript implementation of the IDL, a call to setColorDouble with + Number values that are out of range for a + {{double}} will result in an exception being + thrown. + +
+        // Get an instance of GraphicsContext.
+        var context = getGraphicsContext();
+
+        // Calling the [Unrestricted] version uses allows NaN and non-finite numbers values:
+        context.setColorUnrestrictedDouble(NaN, +Infinity, -Infinity);
+
+        // When setColorDouble is called, floating point values are allowed:
+        context.setColorDouble(-0.9, 1, 1.1);
+
+        // The following will cause a TypeError to be thrown, since NaN and non-finite
+        // number values are not allowed when [Unrestricted] is not specified:
+        context.setColorDouble(NaN, +Infinity, -Infinity);
+    
+
+ +

[Unscopable]

If the [{{Unscopable}}] @@ -14698,6 +14696,7 @@ Daniel Ehrenberg, Brendan Eich, João Eiras, Gorm Haug Eriksen, +ExE Boss, Sigbjorn Finne, David Flanagan, Aryeh Gregor,