lisp(scheme)如何编译成二进制文件?

发布于 2024-10-09 10:21:43 字数 632 浏览 1 评论 0原文

我正在使用具有内置方案解释器的软件。用户可以通过在解释器中键入命令来通信/操作软件。用户还可以将一些二进制文件加载到环境中。我编写了一些像这样的方案代码:

(define test (lambda() (display "This is a test!"))) ---- d:/test.scm

然后将其编译成二进制文件,该文件的加载和执行速度会更快。但该文档没有关于方案代码编译的信息。 编译后,用户可以通过键入以下内容来加载二进制文件:

(fast-load "d:/test.bin" (the-environment))

我认为“快速加载”只是执行读取和评估操作。那么编译只是一个加密过程吗?有人知道这些事情吗?任何信息将不胜感激!提前致谢。

还有另一个例子:AutoCAD 系统。用户可以编写lisp代码来操作AutoCAD。用户可以将 lisp 代码编译成 *.fas 文件,该文件将加载到 AutoCAD 中。那么如果它真的只是一个加密过程,我该如何编写编译器呢?有相关文件吗?

                                                                       Joe

I am using a softerware who has a build-in scheme interpreter. Users can communicate / manipulate the software by typing command in the interpreter. And users also could load some binary file to the environment. I have write some scheme code like this:

(define test (lambda() (display "This is a test!"))) ---- d:/test.scm

And then compile it into binary file which will be loaded and excuted much faster. But the document has no information about compilation of the scheme code.
After compilation user could load the binary file by typing:

(fast-load "d:/test.bin" (the-environment))

I think the "fast-load" just do read and eval things. So does the compilation is just a encrypting process? Does anybody know about these things? Any information will be appreciated! Thanks in advance.

And there is another example: the AutoCAD system. Users can write lisp code to manipulate the AutoCAD. And user could compile the lisp code into *.fas file which will be loaded into AutoCAD. So if it is really only an encrypting process, how can I write a compiler? Is there any documents about it?

                                                                       Joe

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃素的狼 2024-10-16 10:21:44

如果您严格谈论应用程序的内置解释器(根据您的问题似乎就是这种情况),则没有标准答案。您需要查看应用程序设计者是否将编译构建到其实现中并为您公开了该功能。如果不是,那你就不走运了。

如果您要询问独立的Scheme应用程序或库,许多实现(例如Chicken)都提供Scheme编译器某种类型的(前面提到的“鸡计划”首先编译为 C)。

如果您询问 Common Lisp(忽略您在标题和问题中特别提到的事实)。您可以使用标准函数 compile- file,它会生成您在问题末尾提到的 .fasl 格式。

If you are strictly talking about the application's built-in interpreter (as seems to be the case based on your question), there's no standard answer. You'll need to see if the application designer built compilation into their implementation and exposed that functionality for you. If not you're out of luck.

If you were to ask about stand-alone Scheme applications or libraries, many implementations (such as Chicken) provide Scheme compilers of one sort or another (the previously-mentioned Chicken Scheme compiles to C first).

If you were asking about Common Lisp (ignoring the fact that you mention Scheme specifically in your title and question). You can use the standard function, compile-file, which produces the .fasl format you alluded to at the end of your question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文