我怎样才能简单地“运行”?口齿不清文件
Python
当我学习 Python 时,我使用一个漂亮的 gui 安装程序将其安装在 Windows 上,并且所有 .py 文件都会从命令行或资源管理器自动在 python 中运行。
我发现这非常直观和简单,因为我可以立即制作纯文本文件并运行它们。
Lisp
我开始学习 lisp 并决定(根据评论)SBCL 不是一个糟糕的 lisp 实现。
有没有办法设置 SBCL 来像使用 Python 一样轻松地运行 .lisp 文件?
还有其他 Lisp 实现有这个功能吗?
Python
When I learned Python I installed it on windows with a nice gui installer and all .py files would automatically run in python, from the command line or explorer.
I found this very intuitive and easy, because I could instantly make plain text files and run them.
Lisp
I'm starting to learn lisp and have decided (from reviews) that SBCL is not a bad lisp implementation.
Is there a way to setup SBCL to run .lisp files as easily as with Python?
Are there other lisp implementations that have this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可执行文件
SBCL 可以保存可执行映像,正如 Greg Harman 提到的那样(请参阅 :EXECUTABLE 关键字):http://www.sbcl.org/manual/index.html#Saving-a-Core-Image
脚本
Lisp 文件可以是作为脚本执行,请参阅:http://www.sbcl.org/manual/#Shebang-Scripts
命令行选项
SBCL 有命令行选项来在启动时评估/加载 Lisp 代码:http://www.sbcl.org/manual/#Command-Line-Options
SLIME
SLIME 是 Common Lisp 的 Emacs 接口。人们可以在 Emacs 中通过 SLIME 使用 SBCL。许多人更喜欢 Emacs Lisp 监听器而不是典型的 shell 接口。
大多数 Common Lisp 实现都具有类似的功能。有关详细信息,请参阅他们的手册或在此处询问具体实现。
Executables
SBCL can save executable images, as Greg Harman mentions (see the :EXECUTABLE keyword): http://www.sbcl.org/manual/index.html#Saving-a-Core-Image
Scripts
Lisp files can be executed as scripts, see: http://www.sbcl.org/manual/#Shebang-Scripts
Command Line Options
SBCL has command line options to evaluate/load lisp code on start: http://www.sbcl.org/manual/#Command-Line-Options
SLIME
SLIME is an Emacs interface for Common Lisp. One can use SBCL via SLIME from within Emacs. Many people prefer Emacs Lisp listeners over typical shell interfaces.
Most Common Lisp implementations have similar capabilities. For details consult their manual or ask here for specific implementations.
几分钟前,有人回复了接近我正在寻找的答案。
回复链接到 http://www.sbcl.org/manual/Shebang-Scripts.html 这对找出我的解决方案有很大帮助。无论是谁都不应该删除他们的答案,因为我正打算将其标记为正确;)
我的最终解决方案是创建一个批处理脚本,该脚本通过正常的程序文件关联链接作为打开 .lisp 文件的程序(右键单击文件-> 属性 -> 打开方式 -> [更改])。
当您在资源管理器中双击文件时,它会执行它们,当您在命令行中运行它们时,它也会执行相同的操作。
A few minutes ago someone replied with an answer nearing what I was looking for.
The reply linked to http://www.sbcl.org/manual/Shebang-Scripts.html which was a great help in figuring out my solution. Whoever it was shouldn't have removed their answer as I was about to mark it as correct ;)
My final solution was to create a batch script that is linked through normal program file association as the program to open .lisp files (Right click file->Properties->Opens With->[Change]).
When you double click files in explorer it executes them and when you run them in the command line it does the same.
SBCL 可以通过 sb-ext:save-lisp- 保存可执行核心映像然后死掉
SBCL can save an executable core image via sb-ext:save-lisp-and-die
如果您已经下载并安装了 SBCL 解释器,那么为了通过简单地在命令行中输入程序来运行程序,您需要将解释器的位置添加到系统 PATH 变量中,以便您的计算机知道在哪里查找。
对于任何语言都是如此。 Python 安装程序所做的是将 Python 解释器的位置添加到 PATH 环境变量中。
根据您的平台,快速 Google 搜索如何设置环境变量。
If you have already downloaded and installed the SBCL interpreter, then in order to run your programs by simply entering them into the command line you need to add the location of the interpreter to your system PATH variable, so that your machine knows where to look.
This is true for any language. What the Python installer did was add the location of the Python interpreter to your PATH environment variable.
Depending on your platform, do a quick Google search on how to set environment variables.