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

Re: Possible mapping of exceptions



Looks like yes, it is conforming. I hope I did not miss anything
________________________________________
From: stds-1788@xxxxxxxx <stds-1788@xxxxxxxx> on behalf of Dmitry Nadezhin <dmitry.nadezhin@xxxxxxxxxx>
Sent: Thursday, January 12, 2017 10:48 AM
To: Stds-1788
Subject: 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