将命令行参数传递给Clozure common lisp [英] pass command line arguments to Clozure common lisp
问题描述
我以前很熟悉python,现在我试图学习常见的lisp并在Windows系统下使用ccl(clozure common lisp)。
I am familiar with python before and now I am trying to learn common lisp and using ccl(clozure common lisp)under windows system.
我发现有不是将lisp文件作为python运行的便捷方法。所以我写了一个bat文件来编译并运行一个lisp文件。
I found that there is not a convenient way to run lisp file as python. So i write a bat file to compile and run a lisp file.
@echo off
set lisp_filename=%~1
set ccl_path=D:\_play_\lispbox-0.7\ccl-1.6-windowsx86\wx86cl.exe
IF "%PROCESSOR_ARCHITECTURE%" == "x86" (
set fsl_filename=%lisp_filename:.lisp=.wx32fsl%
) ELSE (
set ccl_path=%ccl_path:wx86cl=wx86cl64%
set fsl_filename=%lisp_filename:.lisp=.wx64fsl%
)
IF NOT EXIST %fsl_filename% goto compile
for %%a in ("%lisp_filename%") do (
set lisp_timestamp=%%~ta
)
for %%a in ("%fsl_filename%") do (
set fsl_timestamp=%%~ta
)
IF "%fsl_timestamp%" LSS "%lisp_timestamp%" (
goto compile
) ELSE (
goto run
)
:compile
REM echo "compile"
%ccl_path% --eval "(progn (compile-file \"%lisp_filename:\=\\%\") (ccl:quit))"
:run
REM echo "run"
%ccl_path% --eval "(progn (load \"%fsl_filename:\=\\%\") (ccl:quit))"
:end
一切顺利,但是我找不到将命令行参数传递给lisp脚本的方法。
Everything goes well, but I can not found anway to pass the command line arguments into the lisp script.
我尝试了一个脚本(test.lisp)像这样
(defun main()
(格式t〜{〜a〜%〜} * command-line-argument-list *)
0)(主要)
但是结果是
D:\ _play_\lispbox-0.7\ccl-1.6-windowsx86\wx86cl64.exe
--eval
(progn(load D:\\_play_\\ \test.wx64fsl)(ccl:quit))
我知道此输出是我的bat文件的结果,但我找不到通过的优雅方式
I tried a script(test.lisp) like this
(defun main()
(format t "~{~a~%~}" *command-line-argument-list*)
0 ) (main)
But the result is
D:\_play_\lispbox-0.7\ccl-1.6-windowsx86\wx86cl64.exe
--eval
(progn (load "D:\\_play_\\test.wx64fsl") (ccl:quit))
I know this output is as the result of my bat file, but I can't find an elegant way to pass the command line argument into a lisp script, neither.
有人可以告诉我更多有关如何传递参数的信息吗?
我希望最好的答案可以实现以下内容:
test.lisp abc
并输出< br>
test.lisp
a
b
c
Can anyone tell me more things about how can I pass the arguments?
I wish the best answer can implement something like:
test.lisp a b c
and with a output
test.lisp
a
b
c
任何建议都值得赞赏。 :-)
Any suggestion is very appreciated. :-)
推荐答案
我从其他人那里得到了一些建议,我认为这很有用。
我在这里给出结果,希望对其他人有用。
I have get some suggestion from others, which I think it's really useful. I give the result here, hope to be useful for other ones.
CCL在遇到命令行参数时会停止处理
伪参数-;然后,以下任何参数都可用
作为CCL的值: UNPROCESSED-COMMAND-LINE-ARGUMENTS 。该值
是字符串列表。
CCL stops processing command-line arguments when it encounters a pseudoargument named "--"; any following arguments are then available as the value of CCL:UNPROCESSED-COMMAND-LINE-ARGUMENTS. That value is a list of strings.
console> ccl64 –未处理这些参数
欢迎使用Clozure Common Lisp版本1.7-dev-r14704M-trunk(FreebsdX8664)!
吗? *未处理的命令行参数*
(这些参数 are n't已处理)
这篇关于将命令行参数传递给Clozure common lisp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!