May the defineProperty method of a proxy handler throw a TypeError?

Mark S. Miller erights at google.com
Fri Jun 17 16:11:41 PDT 2011


On Fri, Jun 17, 2011 at 3:47 PM, David Flanagan <dflanagan at mozilla.com>wrote:

> On 6/17/11 3:05 PM, David Bruant wrote:
>
>> What about adding a "throw" argument to the defineProperty trap (and any
>> trap for which the equivalent internal method has a "throw" argument) ?
>> The engine would set the boolean value correctly depending on strict
>> mode or any relevant parameter. Trap writers can adapt their behavior
>> based on this boolean.
>>
>> David
>>
> http://wiki.ecmascript.org/**doku.php?id=harmony:proxies_**semantics<http://wiki.ecmascript.org/doku.php?id=harmony:proxies_semantics>already defines appropriate Reject behavior (return false or throw) for the
> [[Put]] and [[Delete]] operations based on the return value of the put() and
> delete() traps.


Yes, the reason is that a JavaScript callee cannot sense the strictness of
its caller.




>  [[DefineOwnProperty]] is the only one that does not allow it.
>
> Given that the fixed properties proposal is adding a return value to
> defineProperty, perhaps returning false would be a suitable way to reject a
> property definition.
>
>    David
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110617/8a4c2fde/attachment-0001.html>


More information about the es-discuss mailing list