Improving Function.prototype.bind

Mark S. Miller erights at google.com
Fri Jan 6 08:51:50 PST 2012


Alice wouldn't normally be able to communicate 'bound' to Bob, and thus Bob
wouldn't be able to read Alice's 'bound.foo'. The issue is much like ES3's
mistake of evaluation a RegExp literal once to a RegExp object -- everyone
executing the same code could now communicate, even if all accessible
primordial state were frozen.

The answer to both is the same -- the immutable objects they share can only
return mutable objects if these objects are fresh. Alice and Bob can then
separately mutate them without being able to observe each other's
mutations. This is why it is essential that .bind() return a fresh object
each time it is called.


On Fri, Jan 6, 2012 at 12:58 AM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> same thing this does
>
> var bound = Object.bind(Object);
> bound.foo = capabilityBobShouldntGet; // who does this ?
>
> var HAH = bound.foo;
>
> ... so I am missing your point I guess ... but my proposal wants to return
> always same object for 99.9% of usage out there ...
>
>
> On Fri, Jan 6, 2012 at 8:55 AM, Mark S. Miller <erights at google.com> wrote:
>
>> In your proposal, what does this code sequence do:
>>
>>
>>     Object.boundTo(Object).foo = capabilityBobShouldntGet;
>>     var HAH = Object.boundTo(Object).foo;
>>
>> ?
>>
>>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120106/e327d61a/attachment.html>


More information about the es-discuss mailing list