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 14:21:50 -0800
Message-ID: <CA+c2ei9SZFLz94QYV=Sr-qk6TK536cYSM9SZOApw6Rp78cLe8w@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 Wed, Feb 19, 2014 at 1:36 PM, Domenic Denicola
<domenic@domenicdenicola.com> wrote:
>
> From: Jonas Sicking <jonas@sicking.cc>
>
>>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'm trying to understand the specific use case here. Why would passing `undefined` not be "clearly a bug"? Is it because `undefined` is a valid message to post?

Yes.

> In that case, if I were a JS programmer trying to post a message of `undefined`, I would do so by doing `postMessage()`, not `postMessage(undefined)`.

That seems exceedingly awkward. Consider

function processWork(data) {
  if (data === undefined) {
    worker.postMessage();
  } else {
    worker.postMessage(data);
  }
}

vs.

function processWork(data) {
  worker.postMessage(data);
}

/ Jonas
Received on Wednesday, 19 February 2014 22:22:47 UTC

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