[LispM-Hackers] error handling by abusing macro system

James A. Crippen james@UnLambda.COM
Tue, 10 Apr 2001 09:49:02 -0800 (AKDT)


On Mon, 9 Apr 2001, John Morrison wrote:

> Hi;
> 
> (0) Oh, for a *real* macro system!

Sigh.

> (1) Define a macro that causes the program to complain to stderr,
> shoot itself in the head, and leave its corpse in a core file (hmm. A
> CORpsE file?)

No, no, no, no...  That's bad.  Wrong.  Evil.  Rude.

Our program shouldn't be shooting itself in the head.  Ever.  That messes
up the stack, in any case, and makes it hard to do a useful backtrace.

I am vehemently against using bogosity like forcibly causing core
dumps.  We shouldn't be debugging core dumps unless the program created
one by more 'natural' means.  Artificial segfaults are *BAAAD*...

What is it with you and ugly macros, anywa? :)

If you'll just be patient I'll have an error system thrown together
shortly.  I have the hierarchy worked out and am about to put it down in
stone.  I'll be using exceptions and try/catch.  They apparently work
perfectly well, after talking to some programmers.  If we need to do error
handling via some different manner in the future we can wrap up the
exception handling with some interface glue and provide an alternative for
'unexceptional' systems.

I am dead set against using awful kluges for handling errors.  The example
below makes me shudder.  It's worse than some of the garbage I've seen in
the Linux kernel, for instance.  Bad, bad, bad.

C++ is so good as to define a mechanism for handling errors in a clean and
reliable way.  Why don't we use it?  I know it's not always portable, but
I think we can work around that when we come to it.

> #define E3ThrowError(args) { cerr << "E3 THROW:" << args ; abort(); }
> 
> (2) Call the macro like so:
> 
> E3ThrowError("CALL_1_DEST_INDS::execute -- bad DTP target of call = "
>              << (int)operand.getDataType()
>              << endl);
> 
> (3) Replace later with something less, well, embarrassing.

Barf!  It's too embarassing to even put down!  Don't use it!

Ick...

For your sake I'll write up the latest thoughts on the error system in
another message.

'james

-- 
James A. Crippen <james@unlambda.com> ,-./-.  Anchorage, Alaska,
Lambda Unlimited: Recursion 'R' Us   |  |/  | USA, 61.2069 N, 149.766 W,
Y = \f.(\x.f(xx)) (\x.f(xx))         |  |\  | Earth, Sol System,
Y(F) = F(Y(F))                        \_,-_/  Milky Way.