Argument unpacking?

P T Withington ptw at pobox.com
Fri Nov 10 05:24:02 PST 2006


On 2006-11-09, at 17:47 EST, Brendan Eich wrote:

> On Nov 9, 2006, at 2:19 PM, P T Withington wrote:
>
>> On 2006-11-09, at 16:29 EST, Brendan Eich wrote:
>>
>>> It would also be helpful for bootstrapping if new and apply could  
>>> be composed; this came up when I wrote Narcissus.  Suggestions?
>>
>> Make new a class method rather than a keyword?  (I know, too  
>> controversial.  But that is the Lisp answer.)
>
> We could expose intrinsic::construct as the meta-object protocol  
> hook underlying new, and allow you to write, e.g.:
>
>   class Complex! {
>     static intrinsic function construct(real:double,  
> imag:double):Complex {...}
>     . . .
>   }
>
> Then you could always invoke 'Complex.intrinsic::construct.apply 
> (Complex, args)' where args is [real, imag]. Or something simpler  
> to write (static intrinsic function my summer vacation was very  
> nice ;-), but this example is in keeping with the proposed call  
> hook (https://intranet.mozilla.org/ECMA/wiki/doku.php? 
> id=proposals:builtin_classes).  Is this what you mean?

Yes.  In our implementation `new x(...)` is just syntactic sugar for  
`x.make(...)`.  (And make, rather than magically acquiring `this` as  
constructors do, uses `super.make.apply(arguments)`.)



More information about the Es4-discuss mailing list