Functions returning Error codes or actual info

Larry Campbell campbell at redsox.bsw.com
Fri Sep 14 12:16:32 AEST 1990


A number of readers have written asking if the exception handling facility I
described earlier in this thread is publicly available.  It soon will be.
Although I designed it nearly two years ago, I didn't get around to
implementing it until last month.  Our experience with it has been quite
good, but has pointed out a few rough spots that I'd like to iron out before
publishing it; there are also some more or less gratuitous dependencies on
other aspects of our coding environment that most people probably aren't
interested in.  Once the rough edges are filed off and the uninteresting BSW
dependencies are removed, I'll be posting it to alt.sources and
comp.sources.misc.  It should work with any C compiler that supports
setjmp/longjmp; we've used it on VAX/VMS, HP 3000, Wang VS, and PC-DOS with
Turbo C.

In the meantime, an approach very similar to ours is described in a research
report available from the DEC Systems Research Center:

*************** SRC Research Report #40
Date: March 21, 1989

    "Implementing Exceptions in C."
    Eric S. Roberts.
    13 pages.

Author's Abstract

    Traditionally, C programmers have used specially designated return
    codes to indicate exception conditions arising during program
    execution. More modern languages offer alternative mechanisms
    that integrate exception handling into the control structure.
    This approach has several advantages over the use of return codes:
    it increases the likelihood that programming errors will be
    detected, makes it easier to structure the specification of an
    abstraction, and improves the readability of the implementation
    by providing better syntactic separation between handling of
    conventional and exceptional cases. This paper describes a set
    of language extensions to support exception handling in C, and
    a preprocessor-based implementation of those extensions that
    demonstrates both the feasibility and the portability of this
    approach.

-- 
Larry Campbell                          The Boston Software Works, Inc.
campbell at redsox.bsw.com                 120 Fulton Street
wjh12!redsox!campbell                   Boston, MA 02109



More information about the Comp.lang.c mailing list