[comp.lang.pascal] Pascal Exception Handling

martin@bk.dk (Martin_Lester_sps) (03/22/89)

I would like to get some more information on exception handling
in Pascal. We are currently investigating different exception handling
facilities; hopefully being able to pick one "method" and
add it to our compiler.

The following questions are of most interest:

 + What is the current status on exception handling in (extended) Pascal
   standards (what about future directions).

 + What are the implementations of exception handling in commercially
   available Pascal compilers.

 + Implementation issues (specificly on the ANSI X3J9/84-151 proposal).

And why not ask the question: Are exception handlers considered harmfull ? :-)

Thanks for your help

Martin Lester
Bruel & Kjaer Industri A/S
Naerum Hovedgade 18
DK - 2850 Naerum
Denmark
E-mail: martin@bk.dk or mcvax!dkuug!bk!martin

mark@hpcllmr.HP.COM (Mark Rozhin) (03/24/89)

the draft for ansi extended pascal contains nothing on exception handling.

hewlett-packard pascal has defined a structured statement called try/recover.
anything that goes wrong in the try part of the statement (including anything
called from the try part) casues execution to 'jump' to the recover
part. this gives you a nice envelope to enclose any code.

there are some predefined routine to cause an error (called an escape)
explicitly and to find out what the last error was.

for example:

   try
      <stuff>
      <stuff>
      if (<something>) then
	 escape( <number> );
      <stuff>
   recover
      case escapecode of
	 <stuff>

let me know if you want to know more.

m

bobd@ihf1.UUCP (Bob Dietrich) (03/28/89)

In article <236@bk.dk> martin@bk.dk (Martin_Lester_sps) writes:
>I would like to get some more information on exception handling
>in Pascal. We are currently investigating different exception handling
>facilities; hopefully being able to pick one "method" and
>add it to our compiler.
>
>The following questions are of most interest:
>
> + What is the current status on exception handling in (extended) Pascal
>   standards (what about future directions).

JPC (and WG2) felt back in 84 that although such a facility would be useful,
there were other more pressing things that demanded the committee's
attention. The need for exception handling was not felt as pressing back
then. The proposal (finalized in JPC document 84-151) was rejected without
prejudice, meaning it could be brought again later if there was sufficient
interest. There wasn't until after the draft proposed standard for Extended
Pascal got to the point where making any substantive changes would cause too
much additional delay, and so it isn't in the draft. It has been included in
the list of topics that will be examined in the near future.
>
> + What are the implementations of exception handling in commercially
>   available Pascal compilers.
>
> + Implementation issues (specificly on the ANSI X3J9/84-151 proposal).

That proposal was a static "try" sort of mechanism, which is attractive from
the standpoint of potentially generating better code than a dynamic
mechanism. At the same time, it requires more implementation effort than a
dynamic method. For contrast, I'll post the proposal for dynamic exception
handling I included in my public comment on Extended Pascal.
>
>And why not ask the question: Are exception handlers considered harmfull ? :-)

Depends how they're used. I've meet some programmers (I think former PL/I
programmers) that preferred to treat end of file as an exception. I think
that is going overboard. On the other hand, writing a robust application
would be simplified by such a mechanism. Of course, that's assuming
programmers would actually want to find out there's an error in their program
:-).
>
>Thanks for your help
>
>Martin Lester

usenet:	uunet!littlei!intelhf!ihf1!bobd		Bob Dietrich
  or	tektronix!ogccse!omepd!ihf1!bobd	Intel Corp., Hillsboro, Oregon
  or	tektronix!psu-cs!omepd!ihf1!bobd	(503) 696-2092