From: Pascal B. <pj...@in...> - 2003-01-30 00:27:54
|
Here is an extract of aima code: (http://www.cs.berkeley.edu/~russell/code/doc/install.html) whose purpose is to avoid redefining existing functions or macros: ------------------------------(bug-1.lisp)------------------------------ (defmacro define-if-undefined (&rest definitions) "Use this to conditionally define functions, variables, or macros that may or may not be pre-defined in this Lisp. This can be used to provide CLtL2 compatibility for older Lisps." `(progn ,@(mapcar #'(lambda (def) (let ((name (second def))) `(unless (or (boundp ',name) (fboundp ',name) (special-form-p ',name) (macro-function ',name)) ,def))) definitions))) (define-if-undefined (defmacro with-simple-restart (restart &rest body) "Like PROGN, except provides control over restarts if there is an error." (declare (ignore restart)) `(progn ,@body)) ) ------------------------------------------------------------------------ [pascal@thalassa pascal]$ clisp ;; Loading file /home/pascal/.clisprc.lisp ... ;; Loaded file /home/pascal/.clisprc.lisp [1]> (load "bug-1") T [2]> (compile-file "bug-1") Compiling file /home/pascal/src/common/lisp/clisp/bug-1.lisp ... ** - Continuable Error DEFUN/DEFMACRO(WITH-SIMPLE-RESTART): #<PACKAGE COMMON-LISP> is locked If you continue (by typing 'continue'): Ignore the lock and proceed 1. Break [3]> I can't understand why when loading or evaluating directly the macro define-if-undefined, it detects correctly that WITH-SIMPLE-RESTART is FBOUNDP (in COMMON-LISP package), but that when compiling, it does not and tries to redefine it. I've tried to insert some (eval-when (compile load eval) ...) at various places, or even to use [the undocumented! even in the implementation notes] (ext:without-package-lock '("COMMON-LISP")...). I always get this: DEFUN/DEFMACRO(WITH-SIMPLE-RESTART): #<PACKAGE COMMON-LISP> is locked error. So please, how can one compile a source avoiding to redefine functions or macro already defined in COMMON-LISP under CLISP? -- __Pascal_Bourguignon__ http://www.informatimago.com/ ---------------------------------------------------------------------- There is a fault in reality. Do not adjust your minds. -- Salman Rushdie |