Using clozure commond lisp script under windows console

Recently, I am trying to study the common lisp, and this is really an interesting computer language, and I never see such kind of language before, although I have learned C++, python, js and a little java.

I select coluzure common lisp during my study, but I found that using lisp script is not so convenient as python, maybe there is really much difference for python and lisp itself. It is a pity than I have to run a lisp script from a wx86cl.exe internal console every time using “ccl:load”.

I am really want to run the lisp as python and make it more easy to use, so I wrote the following bat script, as well as, solve some kind of problem about passing command line arguments.

@echo off

REM Search for the wx86cl.exe, which should be contained in %PATH%
REM If not found, alert and exist, without run anything

set ccl_exe=wx86cl.exe
FOR %%a IN ( %ccl_exe% ) DO (
    set ccl_path=%%~$PATH:a
IF "%ccl_path%" == "" (
    echo ccl.cmd: Can't find wx86cl.exe, please add it to %%PATH%%
    goto end

REM Because x86-32 and x86-64 is not the same name convention
REM Process the exe path and compile filename

set lisp_filename=%~1

    set fsl_filename=%lisp_filename:.lisp=.wx32fsl%
) ELSE (
    set ccl_path=%ccl_path:wx86cl.exe=wx86cl64.exe%
    set fsl_filename=%lisp_filename:.lisp=.wx64fsl%

REM Compile the file before the lisp source file is changed
REM Bug: cause the time using batch file can just get minite
REM but cannot get seconds, this will lead to unchanged 
REM fsl file to be execute, so I just close the compile
REM logic here.

REM IF NOT EXIST %fsl_filename% goto compile
REM for %%a in ("%lisp_filename%") do (
REM set lisp_timestamp=%%~ta
REM for %%a in ("%fsl_filename%") do (
REM set fsl_timestamp=%%~ta
REM IF "%fsl_timestamp%" LSS "%lisp_timestamp%" (
REM goto compile
REM goto run
REM :compile
REM %ccl_path% --eval "(progn (compile-file \"%lisp_filename:\=\\%\") (ccl:quit))"

REM run the lisp, which means load the lisp file
REM You can get the command line argument using *UNPROCESSED-COMMAND-LINE-ARGUMENTS*
%ccl_path% --eval "(progn (load \"%lisp_filename:\=\\%\") (ccl:quit))" -- %1 %2 %3 %4 %5 %6 %7 %8 %9


And, after saving the content into a ccl.cmd file, you must do also
1. right click a normal lisp file, in “property” dialog, using “ccl.cmd” to open this file always
2. open register via regedit, find the path HKEY_CLASSES_ROOT/lisp_auto_file/shell/open/command
repalce : “some_path_to_ccl_cmd\ccl.cmd” “%1”
to : “some_path_to_ccl_cmd\ccl.cmd” “%1” %*
3. add wx86cl.exe in your system PATH
And, that’s all.

You can use ccl:*unprocessed-command-line-arguments* to get the command line arguments passing to your script file.

So, let us test, make a file test.lisp

(defun main()


D:\>test.lisp 12 foo bar

If you get the same result, it proves that everything is OK, enjoy lisp~


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s