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

Possible mapping of exceptions



Dear WG1788,

I am looking at the section 12.1.3 "Exception behavior" of the full standard.
It says: "The mechanism of how a handler deals with an exception is language-
or implementation-defined.".

Let me consider such C/C++ mechanism. 

1) Define enum Exception which models exceptions.

typedef enum {
  EXC_NONE,
  EXC_UNDEFINED_OPERATION,
  EXC_POSSIBLY_UNDEFINED_OPERATION,
  EXC_INTERVAL_PART_OF_NAI,
  EXC_INVALID_OPERAND
} Exception;

2) Map functions which can signal an exception into language a way
   illustrated by such example.
   Function textToInterval(s) of 1788 is mapped to C function with such synopsis

Exception textToInterval(BareInterval *x, char *s);   

3) Map exception handler to C switch statement

switch (textToInterval(&x, s)) {
   case EXC_UNDEFINED_OPERATION:
      <handle exception>;
      break;
case EXC_POSSIBLY_UNDEFINED_OPERATION:
      <handle exception>;
      break;
}
<continue computation>;

Is this a correct interpretation of 12.1.3 ?
Is this mechanism conforming ?
What is your opinion ?

Best Regards,
  -Dima