Argument unpacking?

Brendan Eich brendan at mozilla.org
Thu Nov 9 14:54:24 PST 2006


On Nov 9, 2006, at 2:47 PM, Brendan Eich wrote:

> 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).

I see in https://intranet.mozilla.org/ECMA/wiki/doku.php? 
id=proposals:builtin_classes (the Object class at least) a 'static  
function new Object() {...}'.  This is, I think, obsolete syntax --  
we do not want to require the class name to be restated after 'new'  
or 'call'.  It may be that we agreed to use 'construct', not 'new',  
as the MOP hook name, since 'new' is reserved and we don't want to  
outlaw direct calls of the static method.

We'll get all this sorted out at next week's TG1 meeting, but the  
upshot seems to be that a static (intrinsic, I think) method for  
constructing instances of a class will be provided by the runtime,  
and it can be overridden to give custom constructor behavior.  Anyone  
see a problem with this approach?

/be




More information about the Es4-discuss mailing list