Use CHAR-EQUAL and STRING for APROPOS.
[jscl.git] / src / documentation.lisp
index 5735e9e..108946e 100644 (file)
@@ -1,12 +1,23 @@
 ;;; documentation.lisp --- Accessing DOCUMENTATION
 
+;;; Documentation.
+(defun documentation (x type)
+  "Return the documentation of X. TYPE must be the symbol VARIABLE or FUNCTION."
+  (ecase type
+    (function
+     (let ((func (fdefinition x)))
+       (oget func "docstring")))
+    (variable
+     (unless (symbolp x)
+       (error "The type of documentation `~S' is not a symbol." type))
+     (oget x "vardoc"))))
+
+
 ;;; APROPOS and friends
 
 (defun map-apropos-symbols (function string package external-only)
   (flet ((handle-symbol (symbol)
-           ;; TODO: it's implementation-dependent, though CHAR-EQUAL seems
-           ;; more reasonable nevertheless
-           (when (search string (symbol-name symbol) :test #'char=)
+           (when (search string (symbol-name symbol) :test #'char-equal)
              (funcall function symbol))))
     (if package
         (if external-only
@@ -33,7 +44,7 @@
      (when (fboundp symbol)
        (format t " (fbound)"))
      (terpri))
-   string package external-only))
+   (string string) package external-only))
 
 ;;; DESCRIBE