On ES Harmony proxies extensibility

Tom Van Cutsem tomvc.be at gmail.com
Tue Jan 25 09:01:34 PST 2011


Re. the cryptic error messages when triggering missing derived or
fundamental traps: is there any reason why an engine can't create
understandable error messages for these cases?

An error message such as "non-callable defineProperty trap on proxy" would
more readily identify the problem than "defineProperty is not a function".

2011/1/24 Tom Van Cutsem <tomvc.be at gmail.com>

> I think there would be a couple of differences between a noop-handler and a
> forwarder-to-an-empty-object.
>
> For one: defining a property on a forwarder-to-an-empty-object would
> actually define the property on the empty object. AIUI, the noop handler
> would silently absorb the assignment. Fixing would also be very different. I
> think forwarding-to-an-empty-object would probably lead to the most
> intuitive behavior. toString() would also work as expected when forwarding
> to an empty object.
>
> One could define a helper function along the lines of:
>
> Proxy.createEmptyHandler = function(proto) {
>   proto = proto || null; // maybe the default should be Object.prototype so
> that toString() works as expected
>   return new Proxy.Handler(Object.create(proto));
> }
>
> I'm not sure whether this is sufficiently convenient to be worth
> standardizing though.
>
> 2011/1/22 Dave Herman <dherman at mozilla.com>
>
> Not sure; I'll think about it. Though abstracting
>> Proxy.Handler(Object.create(null, {})) might in fact be a worthwhile
>> convenience.
>>
>> Dave
>>
>> "Mark S. Miller" <erights at google.com> wrote:
>>
>> >On Fri, Jan 21, 2011 at 2:45 PM, David Herman <dherman at mozilla.com>
>> >wrote:
>> >
>> >> > Should we have a no-op or "sink" standard handler too?
>> >>
>> >> I think so, yes. Especially since you can use that to build one up
>> >that
>> >> implements just the other traps you want to implement, and let the
>> >others
>> >> "fail soft."
>> >>
>> >
>> >How would it be different from
>> >
>> >    new Proxy.Handler(Object.create(null, {}))
>> >
>> >?
>> >
>> >Or, depending on how soft you want to fail
>> >
>> >    new Proxy.Handler(null)
>> >
>> >?
>> >
>> >If there is a useful difference, I have no objection.
>> >
>> >
>> >>
>> >> Dave
>> >>
>> >>
>> >
>> >
>> >--
>> >    Cheers,
>> >    --MarkM
>>
>> --
>> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110125/9170c37a/attachment.html>


More information about the es-discuss mailing list