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

Mark S. Miller erights at
Fri Jun 17 16:29:36 PDT 2011

On Fri, Jun 17, 2011 at 4:20 PM, David Bruant <david.bruant at> wrote:

> I would be much more in favor of traps closely following internal
> methods signature, meaning add "Throw" arguments and let trap writers
> decide of what they want to do with it. Following internal method
> signature sounds a safer way to get around what you need to do.

I agree with the general idea. But rather than make the traps conform to
leaky internal spec methods, let's refactor the internal spec method
signatures to conform to the less leaky signatures we've already achieved
for the traps <

In particular, everywhere we're currently passing in a boolean Throw
argument (which does in fact always indicate strictness) we should instead
be returning a boolean. Then, only the top level interface between special
forms and internal methods need be concerned to turn a failure (false) into
either a silent failure or a throw, depending on the strictness of the
special form. All other internal methods need only propagate such failure
reports back accurately.

> Currently, the "Throw" argument seems bound to strictness (needs to be
> proven, i do not know ES5 by heart), but who knows what it's going to be
> used for in the future (what other contextual information will influence
> its value)?
> ----
> delete(a,Throw){
>  if(Throw)
>    throw new Error();
>  else
>    return false;
> }
> // VS
> delete(a){
>  return false;
> }
> ----
> I think it's more clear for the reader that an error can be thrown from
> the former case. The latter case requires implicit knowledge and may be
> harder to debug. Of course, this is very subjective as I have never had
> the occasion to debug such a code.
> David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list