Wednesday, October 5, 2011

How to "capture" the "fire": exceptions

The exceptions mechanism is supported by the Joshtra language.
To define a new exception type, you have just to add the following statement:

exception <newExceptionType>;

To raise an exception you have to use the fire keyword.
The "fire" term has been inspired by another guy whose crazy mind contributed to the design of this programming language. His name is Paolo "Hooligan" Raimondi.

To catch an exception you have to use the capture construction.

Example:

# Define a new exception type
exception Boom;

capture {
    fire Boom; # raise a Boom exception
} (Boom) {
    #exception handling here
}

No comments:

Post a Comment