(princ) function behavior
I have a simple error trap(defun trap1 (errmsg) (princ "\n An error has occured:\n") (princ errmsg) (setvar "blipmode" OLDBLIPMODE) (setvar "osmode" OLDSNAP) (setvar "LUnits" OLDLUNITS) (setvar "LUPrec" OLDLUPREC) (setvar "cmdecho" oldecho) (setq *error* temperr) (princ))
The (setq *error* temperr) line is supposed to return the error trap to the original function, stored in temperr. Besides being pretty useless, I noticed the (princ) call at the end was causing a bug - the original error trap was not restored.
I am wondering how exactly it happens that having the (princ) line causes this. It is my understanding that the last function evaluated is what is returned from a function, and that calling (princ) returns nil. But why doesn't the side effect of (setq *error* temperr) still happen? I guess the error is not for call to (princ). Should you test the following code?
(defun trap1 (errmsg)(princ "\n An error has occured:\n")(princ errmsg)(if OLDBLIPMODE (setvar "blipmode" OLDBLIPMODE))(if OLDSNAP (setvar "osmode" OLDSNAP))(if OLDLUNITS (setvar "LUnits" OLDLUNITS))(if OLDLUPREC (setvar "LUPrec" OLDLUPREC))(if oldecho (setvar "cmdecho" oldecho))(setq *error* temperr)(princ))
页:
[1]