[Fwd: Fail-fast on non-existing [[Get]]]
herby at mailbox.sk
Tue Oct 16 09:51:38 PDT 2012
This did not get to the list, reposting...
-------- Original Message --------
From: Herby Vojčík <herby at mailbox.sk>
Subject: Fail-fast on non-existing [[Get]]
Date: Fri, 12 Oct 2012 22:42:05 +0200
To: ECMAScript discussion <es-discuss at mozilla.org>
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
Do you think this needs a solution at all? If yes, which option would
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)?
More information about the es-discuss