Roswellã§Common Lispç°å¢ãã»ããã¢ãããã 2016ç§
ï¼2017-3-11æ´æ°ï¼RoswellでCommon Lisp環境をセットアップする - ギークもどきの日記帳
Roswellã¨ã¯ (ãã£ããã¨)
Common Lispã®å¦çç³»ãQuicklispã®ã¤ã³ã¹ãã¼ã«ãå¦çç³»ãã¨ã®ãªãã·ã§ã³ã®éãã®å¸åãªã©ãè¡ãããã便å©ãªãã¼ã«ã Common Lisperãªã使ã£ã¦æã¯ãªãã
ã¤ã³ã¹ãã¼ã«
åç §Wiki
Home · roswell/roswell Wiki · GitHub
Arch Linux
AURã«ç»é²ããã¦ããã®ã§ãyaourtã§ã¤ã³ã¹ãã¼ã«ã§ããã
$ yaourt -S roswell
Homebrew
$ brew install roswell
Windows
Home · roswell/roswell Wiki · GitHub
使ã£ã¦ããOSã®bitã«åããã¦ã32bitãªãRoswell-i686.zip
ã64bitãªãRoswell-x86_64.zip
ããã¦ã³ãã¼ãã解åãPATHãéãã
ã½ã¼ã¹ãããã«ã
INSTALL.mdåç §ã
Replã®èµ·å
ros run
ã³ãã³ãã§REPLãèµ·åããã
$ ros run * (+ 1 2) 3 * (quit) $
ã¾ããroswellã¯ããã©ã«ãã§sbcl-1.2.11ã®ãã¤ããªçã使ãã ä»ã®å¦çç³»ãææ°çã®sbclã使ãããã¨ãã¯ã以ä¸ã®æé ã§ã¤ã³ã¹ãã¼ã«ããã
å¦çç³»ã®ã¤ã³ã¹ãã¼ã« (ä¾: Clozure CL)
$ ros install ccl-bin
å¦çç³»ã®åãæ¿ã (ä¾: Clozure CL)
$ ros use ccl-bin $ ros run Welcome to Clozure Common Lisp Version 1.11-r16635 (DarwinX8664)! CCL is developed and maintained by Clozure Associates. For more information about CCL visit http://ccl.clozure.com. To enquire about Clozure's Common Lisp consulting services e-mail [email protected] or visit http://www.clozure.com. ?
ã¤ã³ã¹ãã¼ã«ã§ããå¦çç³»ã®ãªã¹ãã¯ãros list versions
ã§ç¢ºèªã§ããã
$ ros list version candidates for ros list versions [impl] are: abcl-bin allegro ccl-bin clasp clisp cmu-bin ecl quicklisp sbcl-bin sbcl
ã¤ã³ã¹ãã¼ã«ã§ãããã¼ã¸ã§ã³ã¯ãros list versions [å¦çç³»ã®åå]
ã§ç¢ºèªã§ããã
$ ros list versions sbcl
Installable versions for sbcl:
Checking version to install....
1.3.15
1.3.14
1.3.13
1.3.12
1.3.11
1.3.10
1.3.9
1.3.8
1.3.7
1.3.6
SLIME
ã¿ããªã ãããSLIMEãç°¡åã«ä½¿ããã
ros emacs
ã§ã.emacs.dã®è¨å®ãªãã«SLIMEã使ããemacsãèµ·åãããããã便å©ã
æ®éã®emacsã§ä½¿ãã«ã¯ä»¥ä¸ã®æé ãè¸ãã
$ ros install slime
ç¶ãã¦~/.emacs.d/init.el
ã«æ¬¡ã®è¡ã追è¨ããã
(load (expand-file-name "~/.roswell/helper.el"))
ãã詳ããè¨å®æ¹æ³ã¯ã
Home · roswell/roswell Wiki · GitHub
ãåç §ã®ãã¨ã
Roswell Script
Common Lispã§ã¯RubyãPythonã¨ç°ãªããããã°ã©ã ããã¼ãããREPLãç¨ãããã¨ãå¤ãã ã¹ã¯ãªããè¨èªã®ããã«ãããå¦çãå®è¡ããã«ã¯ãå¦çç³»ãã¨ã«ç°ãªã£ãæ¹æ³ãåããã°ãªããå°ãä¸ä¾¿ãæããã
ãã®ç¹ã解決ãããããRoswellã«ã¯Roswell Script
ã¨ããä»çµã¿ãããã
ros init <ãã¡ã¤ã«å>
ã§ãRoswellãã¤ã³ã¹ãã¼ã«ããã¦ããç°å¢ä¸ã§ãåä½ã§å®è¡ã§ããCommon Lispãçæãããã
$ ros init fact Successfully generated: fact.ros $ cat fact.ros #!/bin/sh #|-*- mode:lisp -*-|# #| <Put a one-line description here> exec ros -Q -- $0 "$@" |# (progn ;;init forms #+quicklisp (ql:quickload '() :silent t)) (defpackage :ros.script.fact.ros.3685511769 (:use :cl)) (in-package :ros.script.fact.ros.3685511769) (defun main (&rest argv) (declare (ignorable argv))) ;;; vim: set ft=lisp lisp:
ãã®ãã¡ã¤ã«ã¯Emacsã¨Vimã®ä¸¡æ¹ã§Common Lispã®ã½ã¼ã¹ã³ã¼ãã¨ãã¦èªèãããã
main
é¢æ°ãã¨ã³ããªã¼ãã¤ã³ãã¨ãªããmainé¢æ°ã®å¼æ°ã«ã¯ãé©åã«ãã¼ã¹ãããã³ãã³ãã©ã¤ã³å¼æ°ã渡ãããã
ä¾ãã°ãå¼æ°ã®éä¹ãè¿ãã³ãã³ãã¯ä¸ã®ããã«ãªãã
#!/bin/sh #|-*- mode:lisp -*-|# #| Calculating the factorial of given number exec ros -Q -- $0 "$@" |# ;;; ä»åã¯ä½¿ç¨ããªãã®ã§ã³ã¡ã³ãã¢ã¦ã ;; (progn ;;init forms ;; #+quicklisp (ql:quickload '() :silent t)) (defpackage :ros.script.fact.ros.3685511769 (:use :cl)) (in-package :ros.script.fact.ros.3685511769) (defun fact (n) (if (zerop n) 1 (* n (fact (1- n))))) (defun main (n &rest argv) (declare (ignorable argv)) (format t "~&Factorial ~D = ~D~%" n (fact (parse-integer n))) 0 ; å®è¡æå ) ;;; vim: set ft=lisp lisp:
å®è¡ä¾
$ ./fact.ros 3 Factorial 3 = 6 $ ./fact.ros 10 Factorial 10 = 3628800
ããã«ãRoswellãã¤ã³ã¹ãã¼ã«ããã¦ããªãç°å¢ã§ãï¼ããããï¼åä½ããexecutableãä½ããã ãã ããå¦çç³»ãã©ã¤ãã©ãªã®ã¤ã¡ã¼ã¸ãå«ãããããã¡ã¤ã«ãµã¤ãºã50MiBããã大ãããªããã¬ãããã«ã¸ã§ã¢!!
$ time ./fact.ros 10 Factorial 10 = 3628800 ./fact.ros 10 0.43s user 0.09s system 98% cpu 0.530 total $ ros build fact.ros $ time ./fact 10 Factorial 10 = 3628800 ./fact 10 0.00s user 0.01s system 89% cpu 0.018 total $ du -ah 54M ./fact 4.0K ./fact.ros
å²ãã¨éããªã£ããæ°ãããããã£ã¨è¨ç®éã®å¤ãå¦çã ã¨å¤§ããå¤ããããã