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

Re: Removing the concept of "optional any"

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Wed, 19 Feb 2014 09:15:15 -0800
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-Id: <337073AA-92E2-48C2-9E4A-0DF389B8F401@wirfs-brock.com>
To: Mark S. Miller <erights@google.com>

On Feb 19, 2014, at 8:28 AM, Mark S. Miller wrote:

> 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?

That's my concern, too.

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

The only real difference between the two is the value of the length property.  However, I think the two declarations (and the associated length value) conveys a different usage expectation.  The first form tells a developer that the common usage is to pass an argument The second form tells a a developer that in common cases an argument is not required.

If you haven't done so, it might be useful to write out for all the  WebIDL signature forms the equivalent ES6 function declarations that you would expect somebody to use when implementing  that WebIDL signature.


Allen
Received on Wednesday, 19 February 2014 17:15:49 UTC

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