高速実行がウリらしいSteel Bank Common Lisp(SBCL)をWindows上で動作するUbuntu(Windows Subsystem for Linux (WSL) )に入れてみる
$ uname -a Linux DESKTOP-TRNV8F8 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux $ sudo apt-get install sbcl Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gyp javascript-common libc-ares2 libfile-basedir-perl libfile-desktopentry-perl libfile-mimeinfo-perl libio-stringy-perl libipc-system-simple-perl libjs-inherits libjs-is-typedarray libjs-psl libjs-typedarray-to-buffer libnet-dbus-perl libnode-dev libnode64 libtie-ixhash-perl libuv1-dev libx11-protocol-perl libxml-twig-perl libxml-xpathengine-perl nodejs-doc python-pkg-resources xdg-utils Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: binfmt-support Suggested packages: sbcl-doc sbcl-source slime The following NEW packages will be installed: binfmt-support sbcl 0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. Need to get 8497 kB of archives. After this operation, 43.5 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 binfmt-support amd64 2.2.0-2 [58.2 kB] Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 sbcl amd64 2:2.0.1-3 [8439 kB] Fetched 8497 kB in 6s (1331 kB/s) Selecting previously unselected package binfmt-support. (Reading database ... 76341 files and directories currently installed.) Preparing to unpack .../binfmt-support_2.2.0-2_amd64.deb ... Unpacking binfmt-support (2.2.0-2) ... Selecting previously unselected package sbcl. Preparing to unpack .../sbcl_2%3a2.0.1-3_amd64.deb ... Unpacking sbcl (2:2.0.1-3) ... Setting up binfmt-support (2.2.0-2) ... Created symlink /etc/systemd/system/multi-user.target.wants/binfmt-support.service → /lib/systemd/system/binfmt-support.service. invoke-rc.d: could not determine current runlevel Setting up sbcl (2:2.0.1-3) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for systemd (245.4-4ubuntu3.2) ...
SBCLを起動してみる
$ sbcl This is SBCL 2.0.1.debian, 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. * (print "hello") "hello" "hello" * (exit)
LISPソースを書いて実行してみる
作成したLISPソース
$ cat hello.lisp (defun test() (print "hello world"))
SBCLを起動してプログラムをロード、関数を実行
$ sbcl This is SBCL 2.0.1.debian, 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. * (load "hello.lisp") T * (test) "hello world" "hello world" * (exit)
スクリプトオプションで自動実行してみる
フォーマット関数による整形版ソース
$ cat hello.lisp (defun test() (format t "~A~%" "hello world")) (test)
scriptオプションを付けて上記ソースを実行。文字列最後に改行が付いた。
$ sbcl --script hello.lisp hello world