[Proxies] Refactoring prototype climbing in the spec

Allen Wirfs-Brock allen at wirfs-brock.com
Thu Nov 10 08:28:34 PST 2011


On Nov 10, 2011, at 1:36 AM, Tom Van Cutsem wrote:

> 2011/11/9 Allen Wirfs-Brock <allen at wirfs-brock.com>
> [[Get]] seems to do nothing but redispatch to [[GetP]] so its definition could be replaced with the body of [[GetP]].
> 
> [[Puit] does a redispatch to [[SetP]] followed by a "mode" based conditional throw depending upon the result of the [[SetP]]. I din't think the the throwing behavior needs (or even should) be over-ride able by a proxy (or even by an alternative internal implementation). I would factor the conditional throw code out of  [[Put]] and make it the responsibility of the caller.  In practice, this just means that I would define a new  Abstraction Operation that is used in place of direct calls to [[Put]].  The abstraction operation wold essentially have the definition you provide for [[Put]] except that it would call [[Put]] instead of [[SetP]] and the definition of [[Put]] would be replaced with the body of [[SetP]]
> 
> Agreed. So if I understood all of that correctly, we would have:
> - Abstract [[GetProperty]] and [[SetProperty]] operations (the methods I called [[GetP]] and [[SetP]])

Yes, current spec. conventions would just call these GetProperty and SetProperty abstract operations. 

> - Object.getProperty and Object.setProperty built-ins that call [[GetProperty]] and [[SetProperty]]

Also, to fully reify property manipulation I think we also need to factor [[Delete]] in a similar manner and provide an Object.deleteProperty built-in that calls the DeleteProperty abstraction operations.

I touch upon this in http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation#a_side_note_on_reflective_property_access (note that this stawman is still under construction)

the basic reason is that just like with Get/Put a handler may want to invoke the primitive behavior of Delete upon the target object without going through the delete operator (which could retrigger a trap).

> - [[Get]] and [[Set]] methods on Objects that call [[GetProperty]] and [[SetProperty]]
> - [[Get]] and [[Set]] methods on Proxies that trigger "get" and "set" traps

Yes, although I prefer to think of [[Get]] and [[Set]] consistently for both Proxy and "normal" objects.  They are polymorphic "traps" that dispatch to a handler that is determined by the nature of the object.  For native objects [[Get]] and [[Set]] dispatch to handlers that just call GetProperty or SetProperty

> - An abstract operation [[Put]](O, P, V, Throw) that calls O.[[Set]](O,P,V) and performs the "strict mode" reject behavior.

Yes, call it Put.


Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111110/699b7be7/attachment.html>


More information about the es-discuss mailing list