[Proxies] VirtualHandler fundamental traps: defaults

David Bruant bruant.d at gmail.com
Sat Dec 17 07:48:00 PST 2011

Le 12/12/2011 16:40, Tom Van Cutsem a écrit :
> (...)
> So in short I would prefer sensible defaults over error-throwing
> missing fundamental traps.
> I'd be interested in hearing others' thoughts about this.
In how they are defined and used, virtual handlers are very much like
the previous proxy design (hence the easy implementation of the previous
design with them).
The reason why one wants to get back to the fundamental/derived
distinction is because she wants to define her own fundamental traps and
that derived traps use her fundamental traps. It seems natural that
derived traps fail if the fundamental trap they relied on has not been
defined/does not exist. That's what happened in the previous design.

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.

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).
For instance, if I want that all enumeration-related derived traps pass
through my getOwnPropertyNames traps, I just define this trap in my
handler which has all derived traps implemented on the VirtualHandler
prototype. The object acts normally except when it comes to enumerating
properties where my Object.getOwnPropertyNames is in control (as per the
default virtual handler derived traps definitions).


More information about the es-discuss mailing list