SBCL(Steel Bank Common Lisp)でコンパイルしてみる。

WIndowsからLispでCOMを使いたい思い調べましたところ、Steel Bank Common Lispが良さそうなのでインストールしてみました。
SBCLについては紫藤のWiki:SBCL(Steel Bank Common Lisp)に詳しい紹介があります。

LISP で win32ole を使いたい訳です。

http://sourceforge.net/projects/sbcl/files/ から1.0.37を開き sbcl-1.0.37-x86-windows-binary.msi をダウンロードし、インストールします。パス名にスペースが入るトラブルを避けるため、 C:\SteelBankCommonLisp\1.0.37 にインストールしました。

テストプログラムは「1594. SBCLでスクリプト」からお借りしました。

;;; test.lisp
(defvar *name-list* '(亀田 前田 上田 コマネチ 誰))

(defun ほげ ()
  (if (null *name-list*)
      'おしまい♪
      (progn
	(format t "俺が~Aだ!!!前説ナシだ、文句あるか!!!~%" (pop *name-list*))
	(ほげ))))

(ほげ)

スクリプトとして実行してみます。

PS C:\SteelBankCommonLisp\1.0.37> sbcl --script test.lisp

This is experimental prerelease support for the Windows platform: use
at your own risk.  "Your Kitten of Death awaits!"
俺が亀田だ!!!前説ナシだ、文句あるか!!!
俺が前田だ!!!前説ナシだ、文句あるか!!!
俺が上田だ!!!前説ナシだ、文句あるか!!!
俺がコマネチだ!!!前説ナシだ、文句あるか!!!
俺が誰だ!!!前説ナシだ、文句あるか!!!

コンパイルしてみます。

PS C:\SteelBankCommonLisp\1.0.37> sbcl
This is SBCL 1.0.37, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.

This is experimental prerelease support for the Windows platform: use
at your own risk.  "Your Kitten of Death awaits!"
* (compile-file "./test.lisp")  ;; ここでファイルのコンパイル。

; compiling file "C:\\SteelBankCommonLisp\\1.0.37\\test.lisp" (written 17 AUG 2010 04:37:59 PM):
; compiling (DEFVAR *NAME-LIST* ...)
; compiling (DEFUN ほげ ...)
; compiling (ほげ)

; C:\SteelBankCommonLisp\1.0.37\.\test.fasl written
; compilation finished in 0:00:00.030
#P"C:\\SteelBankCommonLisp\\1.0.37\\test.fasl"   ;; このファイルが出来ました。
NIL
NIL

実行してみます。

* (load "./test.fasl")
俺が亀田だ!!!前説ナシだ、文句あるか!!!
俺が前田だ!!!前説ナシだ、文句あるか!!!
俺が上田だ!!!前説ナシだ、文句あるか!!!
俺がコマネチだ!!!前説ナシだ、文句あるか!!!
俺が誰だ!!!前説ナシだ、文句あるか!!!
T

関数のコンパイル、逆アセンブル

* (defun add (x y) (+ x y))

ADD
* (compile 'add)

ADD
NIL
NIL
* (disassemble 'add)

; disassembly for ADD
; 0B5E297D:       8B55FC           MOV EDX, [EBP-4]           ; no-arg-parsing entry point
;       80:       8B7DF8           MOV EDI, [EBP-8]
;       83:       E8C8D7A1F5       CALL #x1000150             ; GENERIC-+
;       88:       7302             JNB L0
;       8A:       8BE3             MOV ESP, EBX
;       8C: L0:   8BE5             MOV ESP, EBP
;       8E:       F8               CLC
;       8F:       5D               POP EBP
;       90:       C3               RET
;       91:       CC0A             BREAK 10                   ; error trap
;       93:       02               BYTE #X02
;       94:       18               BYTE #X18                  ; INVALID-ARG-COUNT-ERROR
;       95:       4D               BYTE #X4D                  ; ECX
NIL
* (quit)
PS C:\SteelBankCommonLisp\1.0.37>