如何从Common Lisp REPL提示中检查定义函数的列表 [英] How to examine list of defined functions from Common Lisp REPL prompt

查看:218
本文介绍了如何从Common Lisp REPL提示中检查定义函数的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估/测试基于浏览器的应用程序,大概是用普通的lisp编写的。除了基于浏览器的界面,该软件还提供了一个监听器窗口,其中包含一个'CL-User>'REPL提示符。



我想从REPL提示中检查功能,符号和包的列表。所以我可以将前端功能与通过REPL暴露的功能联系起来。



Google搜索对我来说是徒劳的,因为它导致了教学和教学lisp一步一步的资源。



任何提示,通过REPL检查状态的指针将不胜感激。

解决方案

如果你不知道你正在寻找什么符号,但是要知道你想要搜索什么包,你可以通过仅列出这些特定包的符号来大大减少搜索的数量:$($($)$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b(package(find-package package)))
(do-all-symbols(s lst)
(when(fboundp s))
(如果包
eql(symbol-package s)package)
(push s lst))
(push s lst))))
lst))

(get-all符号sb-thread);返回SB-THREAD包中的所有符号

(get-all-symbols' sb-thread)只是这样。



如果你有一个想法,你想要的是什么类型的符号,一个猜测他们的名字,你可以这样做

 (apropos-listmapc-);返回(SB-KERNEL:MAPC-MEMBER-TYPE-MEMBERS SB-PROFILE :: MAPC-ON-NAMED-FUNS)
(apropos-listmap'cl);返回(MAP MAP-INTO MAPC MAPCAN MAPCAR MAPCON MAPHASH MAPL MAPLIST)

(apropos-list) 返回名称中包含您传入的字符串的所有符号,并选择一个可选的包进行搜索。



只要弄清楚所有这些符号做的好,请尝试: http://www.psg.com/~dlamkins /sl/chapter10.html


I'm evaluating/testing a browser based application presumably written in common lisp. Apart from the browser based interface, the software provides a 'Listener' window with a 'CL-User >' REPL prompt.

I wish to examine the list of functions, symbols, and packages from the REPL prompt. So that I could co-relate the frontend functionality with what is exposed via the REPL.

Google search is futile for me as it leads to tutorials and resources that teaches lisp step-by-step.

Any hints, pointers on examining the state via REPL will be much appreciated.

解决方案

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

这篇关于如何从Common Lisp REPL提示中检查定义函数的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆