Never the less problem still stands, but maybe there are other ways to solve 
it. Only solution I'm left with so far is utility function like this:  

function hasRest(f) {
  return !!~String(f).split('\n').shift().indexOf('...')
}

Which is bad, specially toString of function is not guaranteed to return source.

Maybe alternative solution could be some standard function / method to test if 
the function captures ...rest args.  

Regards
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/


On Saturday, 2012-06-09 at 23:54 , Allen Wirfs-Brock wrote:

>  
> On Jun 9, 2012, at 6:52 PM, Irakli Gozalishvili wrote:
> > I just noticed strange behavior in spider monkey implementation of rest 
> > arguments:  
> >  
> > (function(a, b, ...rest) {}).length // => 2
> >  
>  
> That answer is consistent with what is specified in the ES6 draft spec.  The 
> actual value is specified algorithmically  and is summarized by this note:
>  
>  
> NOTE The ExpectedArgumentCount of a FormalParameterList is the number of 
> FormalParameters to the left of either the rest parameter or the first 
> FormalParameter with an Initialiser. A FormalParameter without an initializer 
> are allowed after the first parameter with an initializer but such parameters 
> are considered to be optional with undefined as their default value.
>  
>  
> See section 13.1.
>  
> The draft is based upon the conclusions that were reached when this was last 
> discussed.  See the thread starting 
> https://mail.mozilla.org/pipermail/es-discuss/2011-August/016361.html  
>  
> There is no obviously "right" answer to what should be reported as the length 
> (and it isn't clear whether this property really has any utility).  The 
> closest thing we have to legacy precedent are these statement from previous 
> versions of the spec:
>  
> 15 Every built-in Function object described in this clause—whether as a 
> constructor, an ordinary function, or both—has a length property whose value 
> is an integer. Unless otherwise specified, this value is equal to the largest 
> number of named arguments shown in the subclause headings for the function 
> description, including optional parameters.
> 15.3.5.1 The value of the length property is an integer that indicates the 
> “typical” number of arguments expected by the function.
>  
> Note that that the the legacy description is not particularly self consistent 
> and that where a length value is "other specified" for various built-in 
> functions it tends to follow the 15.3.5.1 rule.
>  
> Allen
>  
>  
>  

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to