[std-interval] Reply to Steve C.: More on exceptions versus
Stephen.Clamage at Sun.COM
Sun Oct 8 09:55:21 PDT 2006
R. Baker Kearfott wrote:
> At 08:20 AM 10/8/2006 -0700, Steve Clamage wrote:
>>Sylvain Pion wrote:
>>>Steve Clamage wrote:
>>>> >>Dr John Pryce <j.d.pryce at ntlworld.com> writes:
>>>> > Throwing exceptions was shot down for speed and
>>>> > stack-destroying reasons, ...
>>>>I don't see how that situation differs from the solution using a
>>>>global flag. The stack frames between the point of error and the point
>>>>where you check the flag are still lost.
>>>I don't follow. Affecting a value to a global flag does not destroy
>>>anything. Maybe considering examples would make things clearer:
>>>interval f(interval a, interval b, interval c, interval d)
>>> return sqrt(a+b) + sqrt(c+d);
>>>If sqrt() throws, then I cannot get the return value of f.
>>OK, I see. You don't object to the stack-destroying property, you object
>>to the possible need to have try-catch blocks throughout the code.
>>If sqrt did not throw an exception to report an error, I suppose it
>>would return some Interval equivalent of NaN. For sake of argument,
>>let's call it "iNaN", since I believe this point is still under discussion.
> Others, please correct me if I have missed the point or the relevant
> portion of the proposed standard, but I don't think the interval
> "exceptions" would be the same as a "NaN". To refocus, let's consider
> the case:
> In many instances (e.g. in some contexts in constraint propagation), it
> is appropriate to return [0,1], while in others, the fact that part of
> the argument is out of domain needs to be noted. My understanding is
> that throwing an exception in the first case may be too inefficient.
> Thus, the result isn't simply a "NaN."
I'm sorry, I didn't mean to introduce any confusion by talking about a
There is no real number corresponding to sqrt(-1), but if sqrt returns,
it must return some value.
I only wanted to distinguish the case of returning a result when there
is no answer, from throwing an exception instead of returning.
Steve Clamage, stephen.clamage at sun.com
More information about the Std-interval