> -----Original Message----- > From: Michael O'Brien [mailto:[EMAIL PROTECTED] > Sent: 9. mai 2008 11:49 > To: Lars Hansen > Cc: es4-discuss Discuss > Subject: Re: Argument matching > > > Presumably what you're getting at is that if 'checker' is > strict then > > it must accept three arguments even if we only care about > one. This > > is so. > > The easiest way to write down a function like that is to > use the rest > > parameter without a parameter name: > > > > function f(obj, ...) { /* code here */ } > > > Agree, but that may have a performance penalty as the extra > args must be converted to an array.
Why would they have to be converted to an array, if that array can't be referenced? :) > One case where strict mode may be faster than standard ;-) > > So that I can write up a bug for the RI, my take on the rules is: > > - In strict mode, the number and types of args must agree. If > not, an error is generated. > > - In standard mode, you can supply too many actual > parameters, they will be ignored. If you supply too few, > undefined will be automatically supplied for the missing args. In my opinion, yes. But this has not been discussed extensively, and not for a long time, so others may have different understanding. Types must agree in standard mode too, of course (at run-time). --lars > The RI exhibits strict behavior in this regard in standard mode. > > Michael > > > > On May 9, 2008, at 11:37 AM, Lars Hansen wrote: > >> -----Original Message----- > >> From: Michael O'Brien [mailto:[EMAIL PROTECTED] > >> Sent: 9. mai 2008 11:09 > >> To: Lars Hansen > >> Cc: es4-discuss Discuss > >> Subject: Re: Argument matching > >> > >> Comments below: > >> On May 9, 2008, at 10:43 AM, Lars Hansen wrote: > >>> In strict code ("use strict") the number of passed arguments must > >>> match the number of expected arguments. This has been > agreed upon. > >> > >> I presume that is at execution time? > > > > It is. > > > >> So for Array.some in strict mode, the user must supply 3 typed > > arguments > >> for the callback. But in standard mode, they can either > do that, or > > supply > >> one untyped arg. > > > > static function some(object:!Object, checker:Callable, > > thisObj:Object=null): boolean { > > for (let i=0, limit=object.length; i < limit ; i++) > > if (i in object) > > if (checker.call(thisObj, object[i], i, object)) > > return true; > > return false; > > } > > > > The type of 'checker' used to be Checker: > > > > type Checker = function (*, double, Object):boolean; > > > > but that is painful in practice. The intrinsic instance > method still > > requires a Checker, though. > > > > Presumably what you're getting at is that if 'checker' is > strict then > > it must accept three arguments even if we only care about > one. This > > is so. > > The easiest way to write down a function like that is to > use the rest > > parameter without a parameter name: > > > > function f(obj, ...) { /* code here */ } > > > > --lars > > _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
