This did not get to the list, reposting...

-------- Original Message --------
From: Herby Vojčík <[email protected]>
Subject: Fail-fast on non-existing [[Get]]
Date: Fri, 12 Oct 2012 22:42:05 +0200
To: ECMAScript discussion <[email protected]>

Hello!

I have just looked the video on channel9 between Lars Bak and Anders
Hejlsberg, and it gave me one idea.

It seems people sometimes worry about (basically because of a typo) that
they [[Get]] a non-existing property but as it stands, it just returns
undefined and goes happily on.

I see two solutions:
  - add something to the freeze, seal, preventExtensions family which
would set an object to the fail-fast [[Get]] state.
  - use a Proxy in the proto chain to trap the unknown [[Get]] and
throw early

Do you think this needs a solution at all? If yes, which option would
you favour?

Herby

P.S.: In the latter case, I see the possibility of putting
ClosedFormObject (or whatever name) constructor function which would
have a proxy for a .prototype just one step below Object, and let
classes that would want to throw on default-undefined-[[Get]] just
derive from that or its ancestors. Do you think this is minimal enough
so it can be put directly into language (if the solution does not have
some flaws which are not apparent to me)?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to