Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Exceptions vs NaN/NaI



Dima,

How do you envision enabling (3) through defining data types
and operations (my perceived scope of P-1788)?  Note that,
if our standards document is silent on this point, that
does not preclude languages from throwing such an
exception (in a non-standard way, or in a standard-way,
if specified in the language).

Baker

On 04/18/2012 06:17 AM, Dmitry Nadezhin wrote:
It's a good point about trowing an exception.

Some constructors and numeric functions are undefined at Level 1 for some argument values.
Level 2 constructors/functions shall signal failure for such argument values.

There are a few common ways to signal a failure in programming anguages:
1) Set a global/thread-local flag like "errno";
2) Return specifal value like NaI or NaN;
3) Throw a language exception (like in C++ or in Java).

As far as I understand, the draft of the standard recommends(requires) (2).
I don't like (1) too.
However, shouldn't the P1788 be flexible enough to allow
both level 2 operations that signal by (2)
and  level 2 operations that signal by (3) ?

   -Dima



--

---------------------------------------------------------------
Ralph Baker Kearfott,   rbk@xxxxxxxxxxxxx   (337) 482-5346 (fax)
(337) 482-5270 (work)                     (337) 993-1827 (home)
URL: http://interval.louisiana.edu/kearfott.html
Department of Mathematics, University of Louisiana at Lafayette
(Room 217 Maxim D. Doucet Hall, 1403 Johnston Street)
Box 4-1010, Lafayette, LA 70504-1010, USA
---------------------------------------------------------------