开发者

pass command line arguments to 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.

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. :-)


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")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜