Re: foo(...args) [Was: super.apply(this, arguments)]

2008-03-06 Thread Brendan Eich
On Mar 6, 2008, at 10:53 AM, Lars Hansen wrote: http://bugs.ecmascript.org/ticket/357 And Jon Zeppieri kindly implemented this spread (Tucker, have I been misnaming it as "splat"?) operator in the RI. I just commented again in the ticket. /be__

RE: foo(...args) [Was: super.apply(this, arguments)]

2008-03-06 Thread Lars Hansen
Behalf Of P T Withington > Sent: 6. mars 2008 10:48 > To: Brendan Eich > Cc: es4-discuss Discuss; Dean Edwards; Jeff Dyer; Lars T Hansen > Subject: foo(...args) [Was: super.apply(this, arguments)] > > Did the use of ... in the parameter list (in the tail position only, I > assume

foo(...args) [Was: super.apply(this, arguments)]

2008-03-06 Thread P T Withington
Did the use of ... in the parameter list (in the tail position only, I assume) of a function call to 'spread' an array of arguments get accepted into the language? Is the proper way to trampoline all my constructor args to my superclass going to be: class Foo extends Bar { function Foo(.

Re: super.apply(this, arguments)

2008-01-02 Thread Chris Pine
Nathan de Vries wrote: > Sounds similar to the splat operator of Ruby: > > def foo(first, second, *rest) >puts first, second, rest.inspect > end > > foo(1,2) > => 1 2 [] > > foo(1,2,3,4,5) > => 1 2 [3, 4, 5] > > rest = [3,4,5] > foo(1,2, *rest) >

Re: super.apply(this, arguments)

2007-12-22 Thread Nathan de Vries
On 21/12/2007, at 11:56 PM, P T Withington wrote: > Cute! So ... is the 'spread' operator that spreads an array of > arguments into a parameter list. Sounds similar to the splat operator of Ruby: def foo(first, second, *rest) puts first, second, rest.inspect end foo(1,2)

Re: super.apply(this, arguments)

2007-12-21 Thread P T Withington
On 2007-12-21, at 00:39 EST, Brendan Eich wrote: > On Dec 20, 2007, at 4:01 PM, Jeff Dyer wrote: > >> The original Netscape ES4 proposal had syntax for passing arguments >> as an >> array. (Waldemar are you listening?) IIRC it used triple dots like >> this: >> >> foo(...args) >> >> to mean u

Re: super.apply(this, arguments)

2007-12-21 Thread Peter Hall
That is a slightly different feature. ...rest is included for declaring variable length argument lists. But not for passing a variable number of values when you actually make the call. // this is implemented in AS3 function myFunction(...rest){ } // this is not args = [1,2,3]; myFunction(...args)

Re: super.apply(this, arguments)

2007-12-21 Thread Nathan de Vries
On 21/12/2007, at 11:01 AM, Jeff Dyer wrote: > We dropped this from AS3 for lack of evidence for its need. Really? The "rest" arguments (tail arguments specified as an array) is available in AS3 as far as I'm aware: function foo(first:*, second:*, ...rest) { trace(arguments.length

Re: super.apply(this, arguments)

2007-12-20 Thread Brendan Eich
On Dec 20, 2007, at 4:01 PM, Jeff Dyer wrote: The original Netscape ES4 proposal had syntax for passing arguments as an array. (Waldemar are you listening?) IIRC it used triple dots like this: foo(...args) to mean use the elements of 'args' as positional arguments of foo. We dropped thi

Re: super.apply(this, arguments)

2007-12-20 Thread Garrett Smith
> super initializer. This syntax is just letting you override how your > arguments are passed on to your super initializer. What is the > default if I don't specify a call to my super initializer? Does it > get all my arguments, or none of them? > > class A extends B { &

Re: super.apply(this, arguments)

2007-12-20 Thread Jeff Dyer
an usability check. > What is the > default if I don't specify a call to my super initializer? Does it > get all my arguments, or none of them? None of them. > > class A extends B { > function A(x,y,z) : super.apply (this, arguments) { ... } >} > >

Re: super.apply(this, arguments)

2007-12-20 Thread P T Withington
s are passed on to your super initializer. What is the default if I don't specify a call to my super initializer? Does it get all my arguments, or none of them? class A extends B { function A(x,y,z) : super.apply (this, arguments) { ... } } ? Personally, I really don't li

Re: super.apply(this, arguments)

2007-12-20 Thread Graydon Hoare
Peter Hall wrote: > I haven't tried this in the RI, but what about: > > var sup = super; > sup.apply(this, arguments); No, the problem arises from two separate facts: - constructor invocation is not a function call - super-constructor chaining is not a function call either Both of thes

Re: super.apply(this, arguments)

2007-12-20 Thread Peter Hall
I haven't tried this in the RI, but what about: var sup = super; sup.apply(this, arguments); ? Peter On Dec 20, 2007 6:05 PM, Jeff Dyer <[EMAIL PROTECTED]> wrote: > Sorry, I didn't mean to sound so flippant. > > As you may know, super expressions limit the binding of the name after the > dot

Re: super.apply(this, arguments)

2007-12-20 Thread Jeff Dyer
Sorry, I didn't mean to sound so flippant. As you may know, super expressions limit the binding of the name after the dot to the base class bindings. So the fragment above would call the super instance method 'apply', not the super constructor. We could give 'apply' some special meaning when the f

Re: super.apply(this, arguments)

2007-12-20 Thread Dean Edwards
> On 12/20/07 7:20 AM, P T Withington wrote: > >> Ok. I didn't look in the wiki to start with because of that, hence I >> ask on the list: can I apply my super's constructor as in the subject >> line? >> Jeff Dyer wrote: > Sorry, but you can't. > That's a shame. -dean ___

Re: super.apply(this, arguments)

2007-12-20 Thread Jeff Dyer
Sorry, but you can't. Jd On 12/20/07 7:20 AM, P T Withington wrote: > Ok. I didn't look in the wiki to start with because of that, hence I > ask on the list: can I apply my super's constructor as in the subject > line? > > On 2007-12-20, at 10:10 EST, Lars T Hansen wrote: > >> Wiki rot. Th

Re: super.apply(this, arguments)

2007-12-20 Thread P T Withington
Ok. I didn't look in the wiki to start with because of that, hence I ask on the list: can I apply my super's constructor as in the subject line? On 2007-12-20, at 10:10 EST, Lars T Hansen wrote: > Wiki rot. The construct method is long since obsolete. > > The wiki really is wildly out of d

Re: super.apply(this, arguments)

2007-12-20 Thread Lars T Hansen
tt Smith wrote: > > > There's a proposal that, I think, addresses that using construct: > > > > http://wiki.ecmascript.org/doku.php?id=proposals:static_generics > > > > Though in the context of a subclass' constructor, I don't know what > > the syntax wo

Re: super.apply(this, arguments)

2007-12-20 Thread P T Withington
sals:static_generics > > Though in the context of a subclass' constructor, I don't know what > the syntax would be. > > Garrett > > On Dec 19, 2007 9:46 AM, P T Withington <[EMAIL PROTECTED]> wrote: >> Is this permitted syntax in a constructor: >>

super.apply(this, arguments)

2007-12-19 Thread P T Withington
Is this permitted syntax in a constructor: super.apply(this, arguments); for the case where I want to pass all my arguments to my superclass constructor? If not, how does one do that, especially if the constructor I am calling from takes a ...rest arg