如何解释 Ready Lisp 中的完整程序?
我刚刚下载了 Ready Lisp,正在使用 REPL。我想知道的是,如何编写一个长程序,解释它并获得输出?有点像 PLT 方案。
如果可能的话,我希望尽可能减少麻烦。只是想继续阅读我正在读的书。谢谢。
I've just downloaded Ready Lisp and am playing around with the REPL. What I want to know is, how do I write a long program, interpret it and get the output? Sort of like what PLT Scheme has.
I'd like to do this with a minimal amount of hassle if that's possible. Just want to get on with the book I'm reading. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Common Lisp 提供了函数 LOAD 和 编译文件。
LOAD 将加载 Lisp 文本源代码或编译文件并执行那些。
完成的任何打印都将转到通常的输出流。
COMPILE-FILE 允许从文件生成编译文件带有 Lisp 源代码。
它的优点是,使用文件编译器时程序通常运行得更快,并且编译器会进行一些检查并可能给出优化提示。许多实现将生成本机机器代码。然后可以使用 LOAD 加载使用 COMPILE-FILE 生成的文件。
请注意,在 Common Lisp 中,人们通常使用正在运行的 Lisp 来编译和加载代码。在 PLT 方案中,使用的模型是每次“启动”时,代码都会在新的方案中执行。这可能对初学者有帮助,但对于编写较大的软件来说通常是浪费时间。
Common Lisp provides the functions LOAD and COMPILE-FILE.
LOAD will load Lisp textual source code or compiled files and execute those.
Any printing done will go to the usual output streams.
COMPILE-FILE allows to generate a compiled file from a file with Lisp source code.
It has the advantage that the programs are typically running faster when using the file compiler and the compiler does some checking and might give optimization hints. Many implementations will generate native machine code. The file generated with COMPILE-FILE can then be loaded with LOAD.
Note that in Common Lisp one usually uses a running Lisp to compile and load code. In PLT Scheme the model used is that with each 'start' the code gets executed in a fresh Scheme. This may help beginners, but is often a waste of time for writing larger software.
您打开一个新文件 (
example.lisp
),输入源代码,然后执行Cc Cc
编译并加载单个顶级表单,或者Cc Cck
编译并加载整个文件。“编译并加载”意味着修改运行镜像。您不需要在进行小修改后重新编译所有内容,只需重新编译有问题的
defun
表单即可。然后您可以切换到 REPL 并尝试一下。例如,您可以在源文件中输入以下表单:
然后,将鼠标指向该表单,按
Cc Cc
,切换到 REPL,然后尝试一下:You open a new file (
example.lisp
), enter your source code, then doC-c C-c
to compile and load a single top-level form, orC-c C-k
to compile and load the entire file."Compile and load" means that the running image is modified. You do not need to recompile everything after a small modification, but only the
defun
form in question. You can then switch to the REPL and try it out.For example, you might enter this form into your source file:
Then, with point at that form, press
C-c C-c
, switch to the REPL, and try it out: