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 13:50:29 -0800
Message-ID: <CABHxS9h4+yKOzrgXXEbA3A0gSDBvZk9Gy-j_+Z7oAB70H=VqTQ@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, Allen Wirfs-Brock <allen@wirfs-brock.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
These would not be my expectations. Rather, the issue (once again!) is
parametricity vs partial parametricity. If a function takes any first class
value as argument and treats it the same way, I'd expect it to be declared
"any". If a function takes any first class value as argument, but then case
switches its behavior depending on whether the value was undefined, I would
expect it to be declared as "optional any".

For example, although aMap.set(aKey, undefined) means the same thing as
aMap.set(aKey), .set's length should be 2 and its second parameter should
not be considered optional.


On Wed, Feb 19, 2014 at 9:19 AM, Domenic Denicola <
domenic@domenicdenicola.com> wrote:

> At first glance, to me, "any" would mean "anything except `undefined`" and
> "optional any" would mean "anything, including `undefined` to trigger
> defaults."
>
> I'm not sure if that's useful in practice, though.
>
> ________________________________________
> From: Boris Zbarsky <bzbarsky@MIT.EDU>
> Sent: Wednesday, February 19, 2014 12:17
> To: Allen Wirfs-Brock; Mark S. Miller
> Cc: public-script-coord@w3.org
> Subject: Re: Removing the concept of "optional any"
>
> On 2/19/14 12:15 PM, Allen Wirfs-Brock wrote:
> > if you were defining such a function in ES6, you might either write:
> >
> > function f(arg) { }  //this feels like 'any arg'
> >     //f.length is 1
> >
> > or
> >
> > function f(arg=undefined) {}  //this feels like 'optional any arg'
> > //  f.length is 0
>
> That's true.
>
> I suppose we could keep allowing "any" and "optional any" but have them
> processed exactly the same way (basically special-casing "optional"
> processing for "any") except for the .length behavior...  That said,
> would we still want the argc check in that case?
>
> -Boris
>
>


-- 
    Cheers,
    --MarkM
Received on Wednesday, 19 February 2014 21:50:57 UTC

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