[792] in Coldmud discussion meeting
Re: exception handling...
daemon@ATHENA.MIT.EDU (Thu Aug 31 18:07:12 1995
)
Date: Thu, 31 Aug 1995 17:53:09 -0400 (EDT)
From: James C Deikun <jcdst10+@pitt.edu>
To: 869683 Gillespie Brandon James <brandon@smithfield.declab.usu.edu>
Cc: coldstuff@MIT.EDU
In-Reply-To: <9508310725.AA04032@smithfield.declab.usu.edu>
On Thu, 31 Aug 1995, 869683 Gillespie Brandon James wrote:
> I'm mulling over the reconstruction of exception handling (catch) to be
> slightly different. The best way to explain this is with an example:
>
> for obj in (list) {
> catch {
> obj.query_test();
> } handle ~locked {
> sender().print("Object is locked.");
> } handle others {
> sender().print("Error: " + toliteral(error) + " encountered!");
> } otherwise {
> sender().print("Test is sucessful for: " + obj.name());
> valid = valid + [obj];
> }
> }
This isn't an exception handler, it's a switch statement.
> Basically, each handle ~error line is for whichever error, where the
> handle others is for all others. If it does not exist, the error
> is propogated normally.
If you get an unexpected error, why not print a traceback or something,
anyway? It'd be better to spend effort on making a non-cryptic format
for them for nonprogrammers.
If you think it's needed for cleanups, you could be onto something
though. However, is this the best way to implement it? 'finally' is a
very clean and simple thing, for all its disadvantages (like not
inherently knowing if the code inside worked).
> The otherwise clause we are still hung up on, but Jeff Bellegarde and
> I feel it is better than:
>
> for obj in (list) {
> catch {
> obj.query_test();
> sender().print("Test is sucessful for: " + obj.name());
> valid = valid + [obj];
> } handle ~locked {
> sender().print("Object is locked.");
> } handle others {
> sender().print("Error: " + toliteral(error) + " encountered!");
> }
> }
Better only as a switch statement. If you want a switch statement, why
not use one?
--
James "brainwashed convert of LISP folks" Deikun