Re: holes in spread elements/arguments

2011-10-08 Thread Brendan Eich
Hi Sean, I think you make a good case for hole preservation. However, holes in actual and formal parameter lists are not that wanted. You want them for consistency with holes in array pattern destructuring parameters. That's unusual, but I grant that if they're useful for destructuring, they cou

Re: holes in spread elements/arguments

2011-10-07 Thread Andreas Rossberg
On 7 October 2011 17:47, David Herman wrote: > I don't think we can get away with repurposing _ as a pattern sigil, since > it's already a valid identifier and used by popular libraries: > > http://documentcloud.github.com/underscore/ > > In my strawman for pattern matching, I used * as the "

Re: holes in spread elements/arguments

2011-10-07 Thread David Herman
I don't think we can get away with repurposing _ as a pattern sigil, since it's already a valid identifier and used by popular libraries: http://documentcloud.github.com/underscore/ In my strawman for pattern matching, I used * as the "don't-care" pattern: http://wiki.ecmascript.org/dok

Re: holes in spread elements/arguments

2011-10-06 Thread Andreas Rossberg
On 5 October 2011 21:19, Sean Eagan wrote: > However, I don't see why variable declaration array destructuring > binding and parameter lists should be different in any way. The only > current syntactic difference between them is elision: > > // allowed > function f([,,x]){} > // disallowed >

Re: holes in spread elements/arguments

2011-10-05 Thread Sean Eagan
Removing these inconsistencies would also allow argument and parameter lists to be explained in terms of desugaring into array structuring and destructuring patterns respectively: function(a, , c = 0, ...d){  //...} would desugar to: function(){  var [a, , c = 0, ...d] = _arguments_; // even better

Re: holes in spread elements/arguments

2011-10-05 Thread Sean Eagan
On Mon, Oct 3, 2011 at 4:37 PM, Allen Wirfs-Brock wrote: > apply supports holes... > > f.apply(Array(5)); > > Look at the specification of apply in section 15.3.4.3 of the ES5/5.1 spec. >  It does a [[Get]] on each element of the argArray to get the value that > passed in the argument list.  [[Get

Re: holes in spread elements/arguments

2011-10-04 Thread Sean Eagan
On Tue, Oct 4, 2011 at 4:09 PM, Sean Eagan wrote: > On Mon, Oct 3, 2011 at 5:11 PM, Allen Wirfs-Brock > wrote: >> as it currently stands, a function is allowed to use both: >> >> function f(a,b,c,...rest) { >>    g(...arguments); >>    h(...rest); >> } > > Rest parameters are capable of anything

Re: holes in spread elements/arguments

2011-10-04 Thread Sean Eagan
On Mon, Oct 3, 2011 at 5:11 PM, Allen Wirfs-Brock wrote: > as it currently stands, a function is allowed to use both: > > function f(a,b,c,...rest) { >    g(...arguments); >    h(...rest); > } Rest parameters are capable of anything arguments objects are and more, so what use case would there eve

Re: holes in spread elements/arguments

2011-10-03 Thread Allen Wirfs-Brock
On Oct 3, 2011, at 1:00 PM, Sean Eagan wrote: > On Mon, Oct 3, 2011 at 11:35 AM, Allen Wirfs-Brock > wrote: >> >> On Oct 3, 2011, at 8:45 AM, Sean Eagan wrote: >> >>> On Mon, Oct 3, 2011 at 10:30 AM, Erik Arvidsson >>> wrote: But Function.prototype.apply doesn't preserve holes. >>> >>>

Re: holes in spread elements/arguments

2011-10-03 Thread Allen Wirfs-Brock
On Oct 3, 2011, at 12:42 PM, Sean Eagan wrote: > On Mon, Oct 3, 2011 at 11:31 AM, Allen Wirfs-Brock > wrote: >> >> On Oct 3, 2011, at 6:49 AM, Sean Eagan wrote: >> >>> ... > >> In the evolution of the ES language, argument lists predates the existence >> of destructuring. In the legacy lang

Re: holes in spread elements/arguments

2011-10-03 Thread Sean Eagan
On Mon, Oct 3, 2011 at 11:35 AM, Allen Wirfs-Brock wrote: > > On Oct 3, 2011, at 8:45 AM, Sean Eagan wrote: > >> On Mon, Oct 3, 2011 at 10:30 AM, Erik Arvidsson >> wrote: >>> But Function.prototype.apply doesn't preserve holes. >> >> Function.prototype.apply doesn't preserve holes for the the >>

Re: holes in spread elements/arguments

2011-10-03 Thread Sean Eagan
On Mon, Oct 3, 2011 at 11:31 AM, Allen Wirfs-Brock wrote: > > On Oct 3, 2011, at 6:49 AM, Sean Eagan wrote: > >> So I realized hole preservation is actually relevant in both array >> structuring and destructuring.  Array structuring and destructuring >> ellipses forms are both specified in the dra

Re: holes in spread elements/arguments

2011-10-03 Thread Allen Wirfs-Brock
On Oct 3, 2011, at 8:45 AM, Sean Eagan wrote: > On Mon, Oct 3, 2011 at 10:30 AM, Erik Arvidsson > wrote: >> But Function.prototype.apply doesn't preserve holes. > > Function.prototype.apply doesn't preserve holes for the the > `arguments` object, but rest parameters aren't yet standardized, and

Re: holes in spread elements/arguments

2011-10-03 Thread Allen Wirfs-Brock
On Oct 3, 2011, at 6:49 AM, Sean Eagan wrote: > So I realized hole preservation is actually relevant in both array > structuring and destructuring. Array structuring and destructuring > ellipses forms are both specified in the draft spec to preserve holes. > > Argument lists are merely array st

Re: holes in spread elements/arguments

2011-10-03 Thread Sean Eagan
On Mon, Oct 3, 2011 at 10:30 AM, Erik Arvidsson wrote: > But Function.prototype.apply doesn't preserve holes. Function.prototype.apply doesn't preserve holes for the the `arguments` object, but rest parameters aren't yet standardized, and are intended to replace the `arguments` object, so they co

Re: holes in spread elements/arguments

2011-10-03 Thread Erik Arvidsson
But Function.prototype.apply doesn't preserve holes. On Oct 3, 2011 6:50 AM, "Sean Eagan" wrote: > So I realized hole preservation is actually relevant in both array > structuring and destructuring. Array structuring and destructuring > ellipses forms are both specified in the draft spec to preser

argument lists as array structuring patterns and parameter lists as array destructuring patterns (Was Re: holes in spread elements/arguments)

2011-10-03 Thread Sean Eagan
So I guess my deeper question is why we can't just do the following: * argument lists as array structuring patterns: ArgumentList : ElementList * parameter lists as array destructuring patterns: ArrayBindingPattern : [ ArrayBindingElementList ] FormalParameterList : ArrayBindingElementLi

Re: holes in spread elements/arguments

2011-10-03 Thread Sean Eagan
So I realized hole preservation is actually relevant in both array structuring and destructuring. Array structuring and destructuring ellipses forms are both specified in the draft spec to preserve holes. Argument lists are merely array structuring patterns, and parameter lists are merely array d

Re: holes in spread elements/arguments

2011-09-30 Thread Erik Arvidsson
On Fri, Sep 30, 2011 at 15:27, Allen Wirfs-Brock wrote: > > On Sep 30, 2011, at 9:42 AM, Erik Arvidsson wrote: > >> On Thu, Sep 29, 2011 at 12:53, Allen Wirfs-Brock >> wrote: >>> Also, note that I've currently spec'd ES6 so that 'arguments' can be used as >>> a rest parameter name.  In other wor

Re: holes in spread elements/arguments

2011-09-30 Thread Allen Wirfs-Brock
On Sep 30, 2011, at 9:42 AM, Erik Arvidsson wrote: > On Thu, Sep 29, 2011 at 12:53, Allen Wirfs-Brock > wrote: >> Also, note that I've currently spec'd ES6 so that 'arguments' can be used as >> a rest parameter name. In other words >>function foo(...args) {return args} >> and >> function

Re: holes in spread elements/arguments

2011-09-30 Thread Erik Arvidsson
On Thu, Sep 29, 2011 at 12:53, Allen Wirfs-Brock wrote: > Also, note that I've currently spec'd ES6 so that 'arguments' can be used as > a rest parameter name.  In other words >    function foo(...args) {return args} > and >   function foo(...arguments) {return arguments} > are semantically equiva

Re: holes in spread elements/arguments

2011-09-30 Thread Sean Eagan
On Thu, Sep 29, 2011 at 2:53 PM, Allen Wirfs-Brock wrote: > It seems highly desirable that we preserve the existing semantics of arguments I agree, for backward compatability. > and that: >    function foo(...args) { >       assert(length.arguments === length.args}; >       for (let i in argumen

Re: holes in spread elements/arguments

2011-09-29 Thread Allen Wirfs-Brock
On Sep 29, 2011, at 12:14 PM, Sean Eagan wrote: > On Thu, Sep 29, 2011 at 1:31 PM, Allen Wirfs-Brock > wrote: >> >> ... > >> I haven't written the spec. for spread in argument lists but clearly >> interior holes need to be passed as undefined. Trailing holes in a spread >> in the final argu

Re: holes in spread elements/arguments

2011-09-29 Thread Sean Eagan
On Thu, Sep 29, 2011 at 1:31 PM, Allen Wirfs-Brock wrote: > > On Sep 29, 2011, at 11:07 AM, Sean Eagan wrote: > >> Sorry to drag on about array holes, but: >> >> Should holes in spread elements (e.g. [...holeyArray]) and arguments >> (e.g. f(...holeyArray)) reflect as holes in the array they are s

Re: holes in spread elements/arguments

2011-09-29 Thread Allen Wirfs-Brock
On Sep 29, 2011, at 11:07 AM, Sean Eagan wrote: > Sorry to drag on about array holes, but: > > Should holes in spread elements (e.g. [...holeyArray]) and arguments > (e.g. f(...holeyArray)) reflect as holes in the array they are spliced > into to avoid information loss ? The current proposal [1

holes in spread elements/arguments

2011-09-29 Thread Sean Eagan
Sorry to drag on about array holes, but: Should holes in spread elements (e.g. [...holeyArray]) and arguments (e.g. f(...holeyArray)) reflect as holes in the array they are spliced into to avoid information loss ? The current proposal [1] reflects them as `undefined` values. Spread arguments wil