[Proxies] VirtualHandler fundamental traps: defaults

Tom Van Cutsem tomvc.be at gmail.com
Tue Dec 20 05:11:18 PST 2011

2011/12/17 David Bruant <bruant.d at gmail.com>

> I don't think that the default you propose are a good idea, because it
> will make bugs harder to track. Object.getOwnPropertyDescriptor
> returning 'undefined' for any property does not sound like a good idea.
> Likewise for Object.getOwnPropertyNames returning [] systematically.

That is indeed a concern. Abstract methods err on the side of safety.
Default behaviors can turn against you if they don't do what you expected.

> Another idea would be to have no default for virtual handler fundamental
> trap and that the fundamental traps are the default direct proxies traps
> (forwarding to the target).

I don't agree here: the VirtualHandler is designed to support proxy
abstractions that explicitly do not want to "use" their target object, i.e.
they want to ignore the target object as much as possible. VirtualHandlers
are for creating virtual objects (for instance, a remote object proxy for
which there is no real physical target object acting as a backing store).

Indeed, the reason why the VirtualHandler implements the entire handler
API, "overriding" all the default trap behavior, is precisely to avoid
falling back to forwarding to the target.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111220/3d6dfbd3/attachment.html>

More information about the es-discuss mailing list