Lisp HUG Maillist Archive

defining function from common lisp

dear lazyweb,

from peter norvig's paip:

(defun debug (&rest ids)
       "Start debug output on the given ids."
       (setf *dbg-ids* (union ids *dbg-ids*))

but ...

while there is no function debug that this would overwrite, the symbol is exported from common-lisp, and i get a 
continuable error "Defining function DEBUG visible from package COMMON-LISP".

there *is* a restart 'continue however, so i came up with this:

(dspec:def debug
   (handler-bind ((error #'continue))
     (defun debug (&rest ids)
       "Start debug output on the given ids."
       (setf *dbg-ids* (union ids *dbg-ids*)))))

which works, but is this really a good idea?


thanks in advance,
juergen


RE: defining function from common lisp

Hi,

you can shadow debug:

(shadow 'debug)

But I didn't found the debug function in the CLHS, so perhaps it would be
better to move it from COMMON-LISP to some LispWorks specific package.

Regards,

Frank 


Re: defining function from common lisp

Frank Buss wrote:


> you can shadow debug:
> 
> (shadow 'debug)
> 

i could, but then i would have to write (declare (optimize
(common-lisp:debug 3)) or even worse (declare (common-lisp:ignore a b
c)) in all declare/declaim/proclaim forms.

(i did not mention this in my first post, but i'd also like to define
a function ignore, also from PAIP).

thx anyway,
juergen


Re: defining function from common lisp

IIRC, there happen to be four symbols in PAIP that cause problems:

debug, undebug, ignore and symbol.

After a bit of grep'ing, I decided that there were very few instances of these 
symbols in paip and took the low-tech approach.  I manually edited the files 
and changed the names to debug-paip, undebug-paip, ignore-paip and 
symbol-paip.

pt


Updated at: 2020-12-10 08:53 UTC