将命令行参数传递给 Clozure common lisp
我之前熟悉python,现在我正在尝试学习common lisp并在windows系统下使用ccl(clozure common lisp)。
我发现没有一种方便的方法来将 lisp 文件作为 python 运行。所以我写了一个bat文件来编译并运行一个lisp文件。
@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 脚本中的方法。
我尝试了这样的脚本(test.lisp)
<代码>(defun main() (格式 t "~{~a~%~}" *命令行参数列表*) 0)(主要)
但结果是
<代码> D:\_play_\lispbox-0.7\ccl-1.6-windowsx86\wx86cl64.exe
--评估
(progn(加载“D:\\_play_\\test.wx64fsl”)(ccl:quit))
我知道这个输出是我的 bat 文件的结果,但我也找不到一种优雅的方法将命令行参数传递到 lisp 脚本中。
谁能告诉我更多关于如何通过争论的事情? 我希望最好的答案可以实现类似的东西:test.lisp ab c
并有一个输出
<代码> 测试.lisp
一个
b
c
非常感谢任何建议。 :-)
I am familiar with python before and now I am trying to learn common lisp and using ccl(clozure common lisp)under windows system.
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
Everything goes well, but I can not found anway to pass the command line arguments into the lisp script.
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.
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. :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从其他人那里得到了一些建议,我认为这非常有用。
我在这里给出结果,希望对其他人有用。
<代码>
控制台> ccl64 -- 这些参数未被处理
欢迎使用 Clozure Common Lisp 版本 1.7-dev-r14704M-trunk (FreebsdX8664)!
? *未处理的命令行参数*
(“这些”“论点”“未”“处理”)
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.
console> ccl64 -- these arguments aren\'t processed
Welcome to Clozure Common Lisp Version 1.7-dev-r14704M-trunk (FreebsdX8664)!
? *unprocessed-command-line-arguments*
("these" "arguments" "aren't" "processed")