melisgl / named-readtables

The official repo of named-readtables.
Other
66 stars 15 forks source link

Defining method `documentation` visible from package `common-lisp` #27

Closed JensNevens closed 2 years ago

JensNevens commented 2 years ago

The last version of named-readtables, obtained via Quicklisp (release from 20/02/2022), throws an error on compilation.

Error: Defining (METHOD DOCUMENTATION (SYMBOL (EQL #))) visible from package COMMON-LISP { *handle-warn-on-redefinition* is :ERROR }

I encountered this error on mac OS, using LispWorks 8.0.

melisgl commented 2 years ago

Does this help?

diff --git a/src/cruft.lisp b/src/cruft.lisp
index 6e6ea15..0eba2ce 100644
--- a/src/cruft.lisp
+++ b/src/cruft.lisp
@@ -56,24 +56,25 @@
   (prog1 (gethash readtable *readtable-to-docstring*)
     (remhash readtable *readtable-to-docstring*)))

-(defmethod documentation ((name symbol) (doc-type (eql 'readtable)))
-  (let ((readtable (find-readtable name)))
-    (and readtable (gethash readtable *readtable-to-docstring*))))
-
-(defmethod documentation ((readtable readtable) (doc-type (eql 'readtable)))
-  (gethash readtable *readtable-to-docstring*))
-
-(defmethod (setf documentation) (docstring (name symbol)
-                                 (doc-type (eql 'readtable)))
-  (let ((readtable (find-readtable name)))
-    (unless readtable
-      (error 'readtable-does-not-exist :readtable-name name))
+(without-package-lock (#+lispworks :common-lisp)
+  (defmethod documentation ((name symbol) (doc-type (eql 'readtable)))
+    (let ((readtable (find-readtable name)))
+      (and readtable (gethash readtable *readtable-to-docstring*))))
+
+  (defmethod documentation ((readtable readtable) (doc-type (eql 'readtable)))
+    (gethash readtable *readtable-to-docstring*))
+
+  (defmethod (setf documentation) (docstring (name symbol)
+                                   (doc-type (eql 'readtable)))
+    (let ((readtable (find-readtable name)))
+      (unless readtable
+        (error 'readtable-does-not-exist :readtable-name name))
+      (setf (gethash readtable *readtable-to-docstring*) docstring)))
+
+  (defmethod (setf documentation) (docstring (readtable readtable)
+                                   (doc-type (eql 'readtable)))
     (setf (gethash readtable *readtable-to-docstring*) docstring)))

-(defmethod (setf documentation) (docstring (readtable readtable)
-                                 (doc-type (eql 'readtable)))
-  (setf (gethash readtable *readtable-to-docstring*) docstring))
-
 
 ;;;; Mapping between a readtable-name and the actual readtable object.
JensNevens commented 2 years ago

Thank you for your reply. I'm assuming the next release of Quicklisp will contain this fix 👍

melisgl commented 2 years ago

In fact, this was fixed in https://github.com/melisgl/named-readtables/pull/26.