コマンドライン引数をClozure Common Lisp
-
14-11-2019 - |
質問
私はPythonに精通しています、そして今、私は一般的なLispを学び、WindowsシステムでCCL(Clozure Common Lisp)を使いようとしています。
LISPファイルをPythonとして実行する便利な方法がないことがわかりました。そのため、Lispファイルをコンパイルして実行するためのBATファイルを書きます。
@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
--eval
(progn (load "D:\\_play_\\test.wx64fsl") (ccl:quit))
私はこの出力が私のBATファイルの結果としてされていることを知っていますが、コマンドライン引数をLISPスクリプトに渡すエレガントな方法はありません。
誰かが私に引数を渡すことができる方法についてのより多くのことを教えてください。
私は最善の答えが何かを実装できることを望みます:
test.lisp a b c
そして出力
test.lisp
a
b
c
提案は非常に高く評価されています。: - )
解決
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 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
Welcome to Clozure Common Lisp Version 1.7-dev-r14704M-trunk (FreebsdX8664)!
? *unprocessed-command-line-arguments*
("these" "arguments" "aren't" "processed")