gpt4 book ai didi

windows - 将命令行参数传递给 Clozure common lisp

转载 作者:可可西里 更新时间:2023-11-01 10:01:26 24 4
gpt4 key购买 nike

之前熟悉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()
(format t "~{~a~%~}" *command-line-argument-list*)
0 ) (main)

但结果是

D:\_play_\lispbox-0.7\ccl-1.6-windowsx86\wx86cl64.exe<br/>
--eval<br/>
(progn (load "D:\\_play_\\test.wx64fsl") (ccl:quit))

我知道这个输出是我的 bat 文件的结果,但我也找不到将命令行参数传递到 lisp 脚本的优雅方法。

谁能告诉我更多有关如何传递参数的信息?我希望最好的答案可以实现类似的东西:
test.lisp a b c
并有一个输出

test.lisp<br/>
a<br/>
b<br/>
c

非常感谢任何建议。 :-)

最佳答案

我从其他人那里得到了一些建议,我认为这非常有用。我在这里给出结果,希望对其他人有用。

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 -- these arguments aren\'t processed<br/>
Welcome to Clozure Common Lisp Version 1.7-dev-r14704M-trunk (FreebsdX8664)!<br/>
? *unprocessed-command-line-arguments*<br/>
("these" "arguments" "aren't" "processed")

关于windows - 将命令行参数传递给 Clozure common lisp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5494959/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com