The Error type
bruant.d at gmail.com
Sun Aug 19 13:48:57 PDT 2012
Le 17/08/2012 16:11, Brendan Eich a écrit :
> David Bruant wrote:
>> Could what I just described implemented with "value proxies"? I'm not
>> very familiar with the proposal.
> See http://disnetdev.com/talks/virtual_values.pdf and
> http://users.soe.ucsc.edu/~cormac/papers/oopsla11.pdf -- and probably
> more from Cormac and Tim that I don't have at hand right now. Lots of
> applications, no hardcoding for just "error handling".
Thanks for the pointers.
For that matter, I tend to prefer the API described in the paper,
especially with regard to unary/binary trap as opposed to the current
strawman which lists every single operation.
I'd like to add a point about the following use case:
If x is a value proxy, its unary trap is called. If the result of that
is a value proxy too, its test trap will be called; otherwise, no test
trap is called. I think it's unfortunate. If we had an if! statement,
the above could be rewritten as
and the test trap of x would be called. The opposite of its return value
would be used for the test (because of the "!"). Maybe it's a minor
thing, I don't know.
> An idea I first heard from Dave Herman: make an undefined proxy that
> tracks its origin (source coordinates, stack backtrace) and return it
> instead of the one true undefined value, so you can find where that
> missing property was dereferenced.
It seems that the "tainting" extension described in the paper would be
very close to this idea. The careful reader will note that this could be
implemented by engines today ;-)
Actually, to track down missing dereferenced properties from objects you
don't own (built-in objects especially), I think it's even necessary.
I've filed https://bugzilla.mozilla.org/show_bug.cgi?id=783910 for
SpiderMonkey to keep it in mind.
More information about the es-discuss