🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1180

Re: Error returns

#1180
From: brnstnd
Date: Wed, 11 Apr 1990 02:06
20 lines
1750 bytes
In article <1990Apr9.090340.7216@bath.ac.uk> exspes@bath.ac.uk (P E Smee) writes:
> That approach has a lot of good points, but the down side is that there
> is no 'easy and aesthetically pleasing' way of getting both a return
> value, and a success/failure indication, out of a function. 

Actually, it isn't too hard. Just think how you would implement Ada's
exception handling, which, like mostly everything else in Ada, is much
too high level for me to appreciate. Along with the other information on
the stack you pass a pointer to a statement---one per exception handler,
or just one for all exception handlers. The called function raises an
exception by doing the callee's half of function returns, then jumping
to the exception-handling statement. (If there's just one, it uses a
register to indicate which exception it wants.) The exception-handling
statement does the caller's half of function returns and that's it.

The most natural way to do this in C is to pass an appropriately
initialized jmp_buf as a parameter to the function; everything else is
straightforward. Q will have a nicer solution---trust me.

---Dan
Technical Details
Message-ID: <7056:Apr1102:06:0590@stealth.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!think!yale!cmcl2!stealth.acf.nyu.edu!brnstnd
References: <18722.2618C528@urchin.fidonet.org> <1990Apr4.154552.14767@aqdata.uucp> <1990Apr6.102819.9379@bath.ac.uk> <16406@haddock.ima.isc.com> <1990Apr9.090340.7216@bath.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!think!yale!cmcl2!stealth.acf.nyu.edu!brnstnd
From: brnstnd@stealth.acf.nyu.edu
Newsgroups: comp.lang.misc
Subject: Re: Error returns
Message-ID: <7056:Apr1102:06:0590@stealth.acf.nyu.edu>
Date: 11 Apr 90 02:06:05 GMT
References: <18722.2618C528@urchin.fidonet.org> <1990Apr4.154552.14767@aqdata.uucp> <1990Apr6.102819.9379@bath.ac.uk> <16406@haddock.ima.isc.com> <1990Apr9.090340.7216@bath.ac.uk>
Reply-To: brnstnd@stealth.acf.nyu.edu (Dan Bernstein)
Distribution: usa
Organization: IR
Lines: 20