W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2014

Re: Removing the concept of "optional any"

From: Mark S. Miller <erights@google.com>
Date: Wed, 19 Feb 2014 08:28:08 -0800
Message-ID: <CABHxS9g9JcPXCBQ7SF6Sf34Dz1gt4uzptWSs7tF6GHF4JUGzxg@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Hi Boris,

Everything here seems good and compat except the .length issue. Wouldn't
this change cause existing .length values to change, without any other
observable effect on semantics?




On Wed, Feb 19, 2014 at 6:59 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> Right now WebIDL allows arguments of type "any" to be either optional or
> not.
>
> However in the new world where we want to treat undefined and missing
> identically, this doesn't make much sense, since "any" allows any ES value,
> including undefined.  So the only difference between "any" and "optional
> any" is for trailing "any" arguments and the only difference is whether an
> argc check is done.  Well that and conceptually that when undefined is
> passed for an "any" value you get an "any" with the value "undefined",
> while when it's passed for an "optional any" value you get a "not passed".
>  This distinction doesn't seem very useful.
>
> So I would like to propose that we get rid of the concept of optional
> "any" altogether, but just ignore "any" arguments when computing the
> .length of functions or doing the argc checks for required arguments.
>
> So this function would have length 0:
>
>   void f(any arg);
>
> and not throw if called as f().  Doing "void f(optional any arg)" would
> not be valid IDL, though we could allow "void f(optional any arg = null)"
> to avoid changing the grammar, which we would need to do to support "void
> f(any arg = null)".
>
> The other alternative, as discussed in https://www.w3.org/Bugs/
> Public/show_bug.cgi?id=23602, is to remove "undefined" from the value set
> of "any" and then require explicitly opting in to accepting "undefined" by
> saying "optional any".  But that seems a bit odd...
>
> Thoughts?
>
> Note that I've landed this change in current Gecko nightlies for the
> moment to test it out, but I'm pretty darned sure it's web-compatible.
>
> -Boris
>
>


-- 
    Cheers,
    --MarkM
Received on Wednesday, 19 February 2014 16:28:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:51 UTC