aka*_*nuk 3 serialization common-lisp
说我玩SBCL有点没有SLIME,没有任何简单的翻译.现在我想在文件中保存几个函数.不是核心图像,只是文本形式的一些代码.我该怎么办?
有两种方法可以做到:使用DRIBBLE和/或FUNCTION-LAMBDA-EXPRESSION
第一种是DRIBBLE在试验之前始终使用Common Lisp函数:
rjmba:tmp joswig$ sbcl
This is SBCL 1.1.9, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
Run Code Online (Sandbox Code Playgroud)
Dribble采用文本文件的路径名.调用后,交互式IO将写入该文件.
* (dribble "/Lisp/tmp/2013-09-06-01.text")
* (defun foo (a) (1+ a))
FOO
* (foo 10)
11
* (quit)
Run Code Online (Sandbox Code Playgroud)
看文件:
rjmba:tmp joswig$ cat 2013-09-06-01.text
* (defun foo (a) (1+ a))
FOO
* (foo 10)
11
* (quit)
Run Code Online (Sandbox Code Playgroud)
从上面你应该能够看到你是否输入了任何有趣的功能......你也可以设置你的SBCL(例如使用init文件)来始终设置运球.(dribble)没有参数的呼叫结束了运球.
下一个FUNCTION-LAMBDA-EXPRESSION ::
* (defun foo (b) (1- b))
FOO
Run Code Online (Sandbox Code Playgroud)
现在您可以调用FUNCTION-LAMBDA-EXPRESSION以获取定义.它可能会略有改变,但它应该能够恢复以代码编写的有价值的想法:
* (function-lambda-expression #'foo)
(SB-INT:NAMED-LAMBDA FOO
(B)
(BLOCK FOO (1- B)))
NIL
FOO
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
295 次 |
| 最近记录: |