Tech talk on proxies and traits

Dmitry A. Soshnikov dmitry.soshnikov at gmail.com
Tue May 4 01:30:59 PDT 2010


On 02.05.2010 2:33, Brendan Eich wrote:

> Stratifying means native objects need no magic meta methods which can 
> be hijacked by user code. This is important for the spec's soundness, 
> as well as for security and ease of implementation/optimization.

Yep, I see that optimization means that in case if that magic hooks 
would be directly on object that will slow properties/methods resolution 
and handling in general. With proxies it is possible to work with 
original object separately and directly. Just one thing seems as an 
overhead. If a user defines some  magic hooks on object, that means (in 
general) he wants to work with these hooks. And in case of proxies, he 
should work of course with a new proxy, and (maybe) even to forget about 
the original object. From this viewpoint the original object seems is 
not needed any more (besides of course using it inside the proxy's 
handler), i.e. interaction is unilateral -- from proxy to the original 
object. But not vice versa. Although, of course some new/modified 
properties directly on the original object will be reflected in proxy on 
getting.

> Nothing reserved __names__, that is just a Python convention, and C, 
> or really the C pre-processor I suppose. The ship has sailed. Even if 
> we could reserve __names__, mixing traps and base methods is a recipe 
> for spec unsoundness, insecurity, and implementation bugs and slowness.

Yep, slowness goes without saying. So, Python can be named as just a 
"big security hole" then from this viewpoint, I guess?

>
> Proxies avoid all these problems. They are truly winning, we have an 
> implementation nearly done for SpiderMonkey so I can write this as an 
> implementor.

Yep, proxies seems interesting (considering security and slowness issues 
related with direct __names__). Is it possible to test them in nightly 
builds of Firefox? I saw in strawman/harmony examples this construction:

<script type="harmony">

Can it be used already now in nightly builds or it's still just a 
proposal for versioning/typing scripts?

Dmitry.


More information about the es-discuss mailing list