与 Common Lisp 库作斗争
我学习了scheme并很快掌握了很多,然后用它做了一个项目就很好了。我花了几天时间才完成。我现在正在尝试学习 common lisp 来感受一下,现在我真的很难尝试学习 asdf。如何在库中使用它似乎是常识,但我很困惑。我想这是因为大多数 lisp 程序都是在 repl 中编写和运行的,因为一切都工作正常。当我尝试将其编译为可执行文件时,我就失去了位置。
有谁可以给我任何建议或为我提供教程吗?我真的希望能够制作一个可执行文件来提供给人们,而不必解释如何安装 sbcl 和(要求)它然后运行它。我只是想学习用 lisp 做一些我用 schema 做不到的事情。
我想我可以使用scheme并使用ffi来让c库工作,但我没有c的经验。我只是一名出于个人原因学习 lisp 的 Web 开发人员。当然学习一些c和ffi可能不会花这么长时间哈哈。
谢谢
I've learned scheme and quickly mastered a lot of it, then did a project in it just fine. Literally took me days to finish. I'm now trying to learn common lisp to get a feel for that and now I'm just really really struggling with trying to learn asdf. It seems to be common knowledge how to use it with libraries but I'm baffled. I guess it's because most lisp programs are made and run inside the repl because that all works fine. It's when I try to compile it to an executable where I'm loosing my place.
Is there anyone who can give me any advice on it or point me to a tutorial for it? I really want to be able to make an executable to give to people without having to explain how to install sbcl and (require) it then run it. I just want to learn to do something substantial in lisp that I haven't been able to do with scheme.
I guess I could use scheme and use ffi to get c libraries to work, but I have no experience with c. I'm just a web developer learning lisp for my own personal reasons. Of course learning some c and ffi may not take as long as this haha.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要 ASDF 来生成“独立”可执行文件。大多数实现都提供了保存可执行映像的方法,但标准中并未提及如何执行此操作(以及是否要提供)。
一般来说,您会将代码加载到正在运行的映像中,然后“转储”该映像。
例如,在 SBCL 中,您可以使用 sb-ext:save-lisp-然后就死了; CCL 有 ccl:save-application。您必须查看您的实现文档才能了解如何操作。
我现在没有 SBCL,但这个最小的示例应该可以工作(未经测试):
这是一个使用 CCL 的工作示例:
这些可执行映像可能相当大,除非您的实现提供了类似 tree-shaker 之类的东西,但我认为这不应该成为当今的问题。
您可以在 关于此主题的另一个 SO 问题中找到 clisp 的详细示例。
ASDF 文档
You do not need ASDF in order to produce a 'stand-alone' executable. Most implementations provide means to save an executable image, but how to do this (and if it is to be provided at all) is not mentioned in the standard.
In general, you would load your code into your running image and then "dump" that image.
In SBCL for example, you would use sb-ext:save-lisp-and-die; CCL has ccl:save-application. You will have to look in your implementation's documentation in order to find out how to do it.
I don't have SBCL here at the moment, but this minimal example should work (untested):
This is a working example using CCL:
These executable images may be of rather big size, unless your implementation provides something like a tree-shaker, but I do not think that this should be a problem nowadays.
You can find a detailed example for clisp in another SO question about this topic.
ASDF Documentation
这并不完全是您所要求的,但可能会有所帮助。
我也从来没能让 ASDF 很好地工作。有人向我指出了 clbuild ,这是解决类似问题的稍微不同的方法。到目前为止,它对我来说效果很好。
This is not exactly what you asked for, but it might help.
I never could get ASDF to work very well, either. Somebody pointed me at clbuild instead, which is a slightly different approach to a similar problem. It's worked pretty well for me so far.