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

RE: Removing the concept of "optional any"

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 19 Feb 2014 13:30:33 -0800
Message-ID: <CA+c2ei-Fj2rNF=scF75+6jqj1VEt1wvNHX4g5P2r_u9v9_oeTg@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "public-script-coord@w3.org" <public-script-coord@w3.org>, "Mark S. Miller" <erights@google.com>
On Feb 19, 2014 12:17 PM, "Domenic Denicola" <domenic@domenicdenicola.com>
wrote:
>
> I think in general functions that treat not-passed as different from
undefined are *very* surprising and un-JavaScript-ey; I feel like we've
discussed this on this list many times before. `arguments.length` is the
only way to create such functions, and that will be even less possible in
ES6 given the function forms for which `arguments` is not present.
>
> I don't know what behavior is most appropriate for `postMessage()` but it
should be the same as the behavior for `postMessage(undefined)`.

Rather than talk in generalities, I'd really prefer to talk about specific
examples.

`postMessage(x)` sends the javascript value in x to the receiver. Our aim
has been that any values other than callable objects are valid values.

`cursor.update(x)` saves the javascript value in x to the database. Our aim
has been that any values other than callable objects are valid values.

What behaviour do we want in these two specific cases when x is omitted.
I.e. what makes the best API.

I can both see the argument "if you were to naively implement this in JS
omitting x should be equivalent to x === undefined" and "omitting x is
clearly a bug, throw an exception".

I just don't know which argument is stronger.

/ Jonas
Received on Wednesday, 19 February 2014 21:31:00 UTC

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