Re: Removing the concept of "optional any"

On 2/19/14 12:19 PM, Domenic Denicola wrote:
> At first glance, to me, "any" would mean "anything except `undefined`" and "optional any" would mean "anything, including `undefined` to trigger defaults."

This would be the other proposal, yes.  Unfortunately, it's not clear to 
me that this change would necessarily be web-compatible unless we 
changed the existing "any" in postMessage and probably some other places 
(where it's not in trailing position) to "optional any"...

There's another thing worth keeping in mind here, which Allen raised. 
We may want WebIDL to be able to express the "normal" behavior of ES 
functions so that it's possible to use WebIDL to bare-bones describe 
things that might happen to be specified in ECMASpeak or some other 
formalism.  If so, it seems like that behavior would more or less map to:

1)  "any" is allowed, affects .length if trailing, accepts all ES 
values, does NOT trigger an argc check.  Defaults to undefined if not 
passed explicitly.

2)  "optional any" is allowed, does not affect .length if trailing, 
accepts all ES values, defaults to the provided default value, or 
undefined if no default value is provided, if not passed explicitly.

Then your typical ES function like so:

   function f(arg1, arg2=5, arg3=undefined) {}

would look like:

   void f(any arg1, optional any arg2 = 5, optional any arg3);

and have length == 1.

-Boris

Received on Wednesday, 19 February 2014 17:27:19 UTC