develooper Front page | perl.perl6.internals | Postings from September 2002

[perl #17646] [PATCH] Add stone-age exception handling

From:
Brent Dax
Date:
September 28, 2002 04:08
Subject:
[perl #17646] [PATCH] Add stone-age exception handling
Message ID:
rt-17646-38832.16.8411224659481@bugs6.perl.org
# New Ticket Created by  Brent Dax 
# Please include the string:  [perl #17646]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=17646 >


This patch adds a very, very rudimentary form of C-level exception
handling--bringing Parrot beyond the "homo erectus"[1] stage of
exception handling into the stone age.  :^)  It adds a global function
pointer, Parrot_exception_handler(), which is called by
internal_exception() to handle exceptions.  It is passed the error code
(currently always 1) and the text of the message, and can do whatever it
wants with that information--even ignore it, in which case
internal_exception will return to the function that threw the exception.

I don't expect this to be permanent--it's basically there because I'm
working on a Parrot::Interp module (great book, Simon!) and want to
translate the embedding and packfile systems' exceptions into Perl ones.

As a bonus, this patch also fixes embed.c and packfile.c's bad habit of
using fprintf() to report errors.

Finally, it changes the error message format--the text handed to
internal_exception() is surrounded by "Parrot VM: " on one side and
".\n" on the other (at least in the default exception handler).  This
means that I had to edit several tests and touch other files to reflect
the new error message format.

All tests pass, except for t/src, which has never passed on Windows.

[1] Most of you probably know this already, but I've been bitten by
misunderstood comments before, so I'm being careful. *Homo erectus* was
an earlier stage of human evolution, not something a religious
fundamentalist would claim to be an abomination.  :^)

--Brent Dax <brentdax@cpan.org>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
    --Albert Einstein (explaining radio)


-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/38832/31536/410700/patch.txt





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About