W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: Reconciling handling of optional arguments and handling of default values across ES and webidl

From: Rick Waldron <waldron.rick@gmail.com>
Date: Tue, 18 Jun 2013 12:27:07 -0400
Message-ID: <CAHfnhfowHk5D0_=PPuOoKv_YVPRY_QTjDpWqcfRBxjkfLzXCOQ@mail.gmail.com>
To: Allen Wirfs-Brock <allen@wirfs-brock.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, Cameron McCormack <cam@mcc.id.au>, Brendan Eich <brendan@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Allen, I've updated
http://wiki.ecmascript.org/doku.php?id=harmony:parameter_default_values to
include the boilerplate "proposal has progressed to the Draft ECMAScript 6
Specification" notification.

Rick


On Tue, Jun 18, 2013 at 11:52 AM, Allen Wirfs-Brock
<allen@wirfs-brock.com>wrote:

>
> On Jun 18, 2013, at 8:18 AM, Boris Zbarsky wrote:
>
> > On 6/18/13 11:00 AM, Allen Wirfs-Brock wrote:
> >> Cameron, Either I'm misinterpreting what you are trying to say or you
> misunderstand what Boris said.  ES6 does allow a parameter with an explicit
> default value to be followed by one without an explicit default value.
> >
> > I think part of the issue here is that the state of "ES6" is unclear to
> at least me.
> http://wiki.ecmascript.org/doku.php?id=harmony:parameter_default_valuessays:
>
> The specification drafts is what you need to be reading as old wiki
> proposals are seldom updated.  Only refer to the wiki for proposals (such
> as modules) that have not yet made it into the draft.
>
> >
> >    Added restriction not expressed by this grammar: only trailing
> >    formal parameters may have default values specified by =
> >    AssignmentExpression
>
> That text dates to 2009.  The current specification is based upon
>  subsequent es-disuss and TC39 discussions.
>
> >
> > and that matches what SpiderMonkey, at least, implements:
>
> implementors really need to read the spec. and not just wiki pages
>
> >
> >  js> function f(a = 5, b) {}
> >  typein:1:18 SyntaxError: parameter(s) with default followed by
> >  parameter without default:
> >  typein:1:18 function f(a = 5, b) {}
> >  typein:1:18 ..................^
> >
> > and what SpiderMonkey developers I asked about the behavior told me the
> spec says.  On the other hand
> http://people.mozilla.org/~jorendorff/es6-draft.html has quite different
> language which matches what you're quoting.  Has the spec just changed
> recently?
>
> No, the line I quoted was added to the spec. in May 2012 and it was just
> added for clarification (from a previous time this issue came up). It looks
> like it originally made it into the spec. in October 2011.  (BTW, I think
> Jason is one draft behind.  Probably my fault...).
> >
> > It's not clear to me whether the current spec allows this:
> >
> >  function f(a, b = 5, c, d = 7, e) { }
> >
> > If it does, great; that basically matches what I'm proposing WebIDL
> should do, which is allow putting default values on the optional arguments
> where they make sense no matter what the argument order is.
>
> Yes it does.  It remains the case in ES6 that all formal parameters are
> actually "optional".  The only real issue is what initial value they get if
> a corresponding argument is not present.
>
> >
> >> This is all about determining the "length" value of a function.  Length
> is the number of required arguments which is defined to be the number of
> formal parameters to the left of  the first parameter with a default value
> initializer (or the rest parameter).
> >
> > The "length" of a function is an orthogonal (and somewhat simpler, in
> that it really doesn't matter all that much in practice, imo) issue. Right
> now we're just talking about what sort of functions are allowed at all.
> >
> > -Boris
> >
>
>
>
Received on Tuesday, 18 June 2013 16:27:57 UTC

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