On Thu, Sep 18, 2008 at 11:49 PM, Erik Arvidsson
<[EMAIL PROTECTED]> wrote:
> On Thu, Sep 18, 2008 at 10:41, Garrett Smith <[EMAIL PROTECTED]> wrote:
>> 2008/9/18 Mark S. Miller <[EMAIL PROTECTED]>:


>
> There is really no point in exposing the two different cases in a
> spec.  A spec should describe the semantics, not the implementation.
>

OK.

Another version:
================================================
Function.prototype.bind( context, [ preArg1 [, preArg1 [,...]]])

1. if this object does not have a [[Call]] property, throw a
TypeError
2. let FUN = this
3. let PREARGS = a copy of the argument list provided by the caller,
starting from position 1.
4. Call [[Get]] method of PREARGS with argument "length".
5. let RETFUN = a new Function object.
6. let POSTARGS = a copy of FUN's argument list, starting from
position Result(4).
7. Set RETFUN's FormalParameterList to POSTARGS.
8. let SCOPE = a new Object.
9. For each property in PREARGS, create a Property on SCOPE with a
corresponding name and value.
10. Set RETFUN's scope chain to SCOPE
11. Set the Base object for RETFUN to context.
12. Return RETFUN.

The length property of the bind method is 1.
================================================

Shorter. A little easier to read in that it has no branch.

What about step 11?
11. Set the Base object for RETFUN to context.

The problem I see with that is that given:

var n = f.bind(o);
n.call(p);

n.call will set the execution context to p. That seems wrong. n should
always execute in context of o. Shouldn't it?

Interesting Side effect: The returned function's length is FUN.length
- PREARGS.length;

Thoughts?

Garrett

>> ================================================
>>
>> ?
>>
>> Garrett
>>
>>> --
>>>    Cheers,
>>>    --MarkM
>>>
>>> _______________________________________________
>>> Es-discuss mailing list
>>> Es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>> _______________________________________________
>> Es-discuss mailing list
>> Es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
>
> --
> erik
>
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to