Kaja is writing a series of articles on the shortcomings and solutions to the current object paradigm. Very interesting.
Tag: semantics
Typed Yields: Non fatal exceptions
Wouldn’t it be nice to have:
begin {
&nsbr;LoadTheDatabase("foo.bar");
} rescue (Exception e) {
print "Fatal exception happened: ", e
} on (Warning w) {
print "Database Warning: ", w
} on (Message m) {
print "Database Message: ", m
}
The rescue (Exception e)
should be familiar with everyone — something failed, maybe the database file was corrupted very bad, and raised an exception and the rescue
block will be executed.
But what if the database has a small error, or something is only a little bit out of place. You wouldn’t want to just ignore it, but warn about it. Usually one would implement a ‘Logger’ class to which a function can log certain events, but that is ugly and inconvenient.
Enter non fatal exceptions. Basically there would be two ways to raise an exception, fatal like we all know it, and non fatal. When the on
block for a non fatal exception has been executed, control will be returned to the function in which the raise
was called.
This is done in about the same ways as a lot of languages implement yield
. But this time the handling code depends on the type of the yielded object.
As far as Kaja and I concern this will be a feature of Paradox.
Thanks go to Bram for the idea.