[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]

Browsing throughh the wonderful LISPM manual, an idea or two...

One thing I have always found tricky, even dealing with my own
code, is that often when I get a correctable error it is not clear
what the precise effect of proceeding or restarting will be.
As a simple example, WRNG-TYPE-ARG and WRNG-NO-ARGS errors in
MacLISP, though their names are similar, do completely different
things with the object given to proceed with.  Often in my own code,
for lack of a better error category, I use FAIL-ACT (I see this is
not a restriction in the LISP Machine), but then can't figure oout
what happens when I continue without looking at the code.
It occurs to me that an error message should always be accompanied
by a message describing the effects of proceeding or restarting
(or even, for that matter, aborting).
Now as long as the CERROR function in LISPM has these two flags
"proceedable-flag" and "restartable-flag", I would like to suggest
institutionalizing the following convention: a non-NIL value foor
such a flag shoould by convention be a string describing the result
oof taking the action permitted by that flag.  These strings should
be available to the handler.  The default handler should be
prepared to print them in response to ? or HELP.
	(cerror "the value will be returned as that of the call"
		"The call to ~A used the inconsistent arguments ~A."
		the-fn the-args)
	(cerror "the value should be a stream to use instead"
		"I will try again to establish the CHAOSnet connection"
		"CHAOSnet site ~A is not responding"
[In the first example, I spuriously gave the-fn as an argument, which
ought to be there, contrary to the manual?]  For the second
example, typing HELP at the debugger might say, among other things:
	If you proceed (Control-C), the value should be a stream to use instead.
	If you restart (Meta-C), I will try again to establish the CHHAOSnet connection.
I haven't worked out all the details, but you get the general idea.
[By the way, haucome the error type :invalid-function doesn't let you
specify the function to use, instead of just aborting the whole call?]

An idea for CHECK-ARG is that it could use property lists in an
organized way too save typing.  The basic idea is (don't implement
it this way!!!):
	(defun check-arg (&quote varname &eval type-symbol &optional
				(predicate (fsymeval type-symbol))
				(description (or (get type-symbol 'check-arg-description)
					(string-append "something that satisfies "
						(cond ((symbolp predicate) ;ugh
							(t type-symbol))))))
In this way  (CHECK-ARG A 'NUMBERP) [possibly without the quoote mark?]
would suffice, probably in conjunction with
(DEFPROP NUMBERP "a number" CHECK-ARG-DESCRIPTION).  [Again, this is
perhaps not the most flavorful way to go aboout it.]

Finally, it seems a shame that I cannot compute a function for
CHECK-ARG because oof its weird form/symbol hack on
its secoond "argument" -- it is reminiscent of the computed GO hack
or SSTATUS CHTRAN.  I might want to write
			   (T (ERROR ...)))
		   (FORMAT NIL "of the same type as ~A" A)).
Oh well.
-- Q