且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Common Lisp REPL提示中检查定义函数的列表

更新时间:2023-11-28 19:38:58

If you don't know what symbols you're looking for, but do know what packages you want to search, you can drastically reduce the amount of searching you have to do by only listing the symbols from those specific packages:

(defun get-all-symbols (&optional package)
  (let ((lst ())
        (package (find-package package)))
    (do-all-symbols (s lst)
      (when (fboundp s)
        (if package
            (when (eql (symbol-package s) package)
              (push s lst))
            (push s lst))))
    lst))

(get-all-symbols 'sb-thread) ; returns all the symbols in the SB-THREAD package

The line (get-all-symbols 'sb-thread) does just that.

If you have an idea about what type of symbols you're looking for, and want to take a guess at their names, you can do this

(apropos-list "mapc-") ; returns (SB-KERNEL:MAPC-MEMBER-TYPE-MEMBERS SB-PROFILE::MAPC-ON-NAMED-FUNS)
(apropos-list "map" 'cl) ; returns (MAP MAP-INTO MAPC MAPCAN MAPCAR MAPCON MAPHASH MAPL MAPLIST)

(apropos-list) returns all symbols whose name contains the string you pass in, and takes an optional package to search.

As far as figuring out what all those symbols do, well, try this: http://www.psg.com/~dlamkins/sl/chapter10.html

上一篇 : :无效的Swift Support/SwiftSupport文件夹为空下一篇 : 合并/展平一个数组

相关阅读

推荐文章