-----Pôvodná správa-----
From: Tom Van Cutsem
Sent: Wednesday, December 21, 2011 8:42 PM
To: Herby Vojčík
Cc: Andreas Rossberg ; Brendan Eich ; es-discuss
Subject: Re: Are Private name and Weak Map the same feature? and the Assoc
API
2011/12/21 Herby Vojčík <[email protected]> From: Andreas Rossberg
Unfortunately, I don't have a good suggestion for a convenient
interface, besides introducing a sentinel value that traps can return
(I am still puzzled how people can survive in dignity without variants
and tuples... :) ).
===
I was proposing some solutionto exactly this in "Forward proxies with
private names" thread. Not acceptable (especially the call, if exception is
too hard to swallow)?
Two reasons against:
1) Probably introduces a high overhead, since it implies every trap
invocation needs to be wrapped in a try-block to catch the exception. Under
no circumstances should such an exception unwind the stack any further, to
avoid confusing other trap invocations on the stack.
2) Misuse of exceptions: asking a proxy to "please forward" is not an
exceptional situation. I was taught it is bad API design to abuse exceptions
for non-exceptional situations.
The cleanest approach so far seems to be to either return a per-call unique
sentinel value or a tuple (true, realReturnValue) or false. Both introduce
extra per-call allocation, and add more complexity to an already complex
API. I would not consider either to be a big improvement over proxies not
being able to forward private names unknown to them.
======
What about the second possibility that was there (calling a specific call to
signal "please forward")? In my original proposal it would break execution
of the trap immediately, but it is probably just an exception in disguise -
it can be so that such a call sets a flag "please forward" and the trap
function is allowed to run along until it does a return and after that
return, the proxy machinery does the forwarding. No need to complicate
return values by tuples, then, just set the flag and return.
======
Cheers,
Tom
======
Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss