Skip to main content

Common Lisp 설치하기

왠지 요새 Lisp을 공부해야될것만 같은 기분이 들어 책을 빌려 보기 시작했습니다. ((Practical Common Lisp, Peter Seibel, APRESS, 2005)) Ruby에 Lisp에... 요새 갑자기 모르는 프로그래밍 언어 공부에 필받았네요. ;-)
이번 글은 제가 사용하기로 한 SBCL와 SLIME의 설치 방법입니다.

Requirements

  1. Linux 머신
  2. emacs
  3. SBCL: Steel Bank Common Lisp
  4. SLIME: The Superior Lisp Interaction Mode for Emacs
SLIME는 emacs의 mode로 Lisp 프로그래밍을 위한 IDE라고 보시면 됩니다. ((Intergrated Development Environment))

Installation

SBCL

  1. 다운받은 sbcl-0.9.12-x86-linux-binary.tar.bz2의 압축을 풉니다.
  2. $ sh install.sh을 실행시킵니다.
    - 이때 root 권한이 없어 자신의 홈디렉토리 밑에다 생성해야 할 경우에는 다음과 같이 INSTALL_ROOT 환경 변수를 셋팅한 후 install.sh을 실행시킵니다. 아래 내용은 자신의 홈디렉토리 밑에 생성한 경우를 대상으로 설명합니다.
    $ export INSTALL_ROOT=${HOME}
    
  3. 환경 변수에 다음과 같은 내용을 추가합니다.
    export PATH=${PATH}:${HOME}/bin
    export SBCL_HOME=${HOME}/lib/sbcl
    
  4. $ sbcl이 정상적으로 실행되는지 확인합니다.

SLIME

  1. 다운받은 slime-2.0.zip의 압축을 풉니다.
  2. 디렉토리의 이름을 slime으로 바꾼 후 적당한 디렉토리로 옮겨 놓습니다. 저의 경우에는 아래 디렉토리를 사용했습니다.
    ${HOME}/etc/slime
  3. emacs 파일에 아래 내용을 추가합니다.
    (add-to-list 'load-path "~/etc/slime/") ; your SLIME directory
    (setq inferior-lisp-program "~/bin/sbcl") ; your Lisp system
    (require 'slime)
    (slime-setup)
    
    (setq auto-mode-alist (cons '(".cl$" . lisp-mode) auto-mode-alist))

Usage

  1. emacs를 실행시킵니다.
  2. M-x slime을 입력하면 CL-USER> 프롬프트가 나오는 창이 생성됩니다. 이 창이 REPL 창입니다. ((Read-Eval-Print Loop))
  3. 끝내려면 콤마(,) 입력 후 quit를 입력합니다.
  4. 수행 도중 debug 모드에서 나오려면 'q' 를 입력합니다.

간단한 키바인딩은 다음과 같습니다.

^ 키 ^ 의미 ^
| C-c C-q | 괄호 닫기 |
| C-c C-c | 컴파일 |
| C-c C-l | 파일 로딩 |
| C-c C-k | 현재 버퍼 컴파일 & 로딩 |

이제 Lisp 프로그래밍을 해볼까요?

CL-USER> (+ 2 3)
5
CL-USER> (format t "Hello, world")
Hello, world
NIL

:-)

Comments

  1. Practical Common Lisp은 어디서 빌리신 건가요? 이 책을 소장한 공공도서관이 있나요?

    ReplyDelete
  2. 아뇨... 회사 도서관에서.
    절반쯤 보다가 반납했습니다. ANSI Common Lisp이라는 책이 또 나왔던데... 책을 빌려보는 것의 단점으로 다른 사람이 예약하면 2주만에 반납해야 해서 자꾸 흐름이 끊기네요. 한권 사야 할런지... :-|
    덕분에 아직 lisp의 강력함에 반하지 못하고 있습니다. :-)

    ReplyDelete
  3. iwongu님의 수준에 도움이 되실지 모르겠지만 전 처음에 http://www.lisperati.com/ 여길 접속해서 풍미를 익혔습니다.

    ReplyDelete
  4. lisp에 관해선 아직 수준이랄만한게 없습니다. 추천해 주신 사이트로 저도 lisp의 세계에 발을 들여놓을 수 있었으면 좋겠네요. :-)

    ReplyDelete

Post a Comment

Popular posts from this blog

CodeHighlighter plugin test page.

This post is for testing CodeHighlighter plugin which uses GeSHi as a fontifier engine. ((Those code blocks are acquired from Google Code Search .)) ((For more supported languages, go CodeHighlighter plugin or GeSHi homepage.)) C++ (<pre lang="cpp" lineno="1">) class nsScannerBufferList { public: /** * Buffer objects are directly followed by a data segment. The start * of the data segment is determined by increment the |this| pointer * by 1 unit. */ class Buffer : public PRCList { public: Buffer() { ++index_; } PHP (<pre lang="php" lineno="4">) for ($i = 0; $i $value = ord( $utf8_string[ $i ] ); if ( $value < 128 ) { // ASCII $unicode .= chr($value); } else { if ( count( $values ) == 0 ) { $num_octets = ( $value } $values[] = $value; Lisp (<pre lang="lisp">) ;;; Assignment (define-caller-pattern setq ((:star var fo...

C++ of the Day #43 - SQLite3 C++ wrapper #1

The Definitive Guide to SQLite 를 읽다가 공부 겸 해서 C++ wrapper를 만들어 보았습니다. 최대한 C++ 냄새(?)가 나도록 만들어 보았습니다. :-) ((SQLite는 복잡한 관리가 필요없이 사용가능한, 파일이나 메모리 기반의, 라이브러리로 제공되는, 약 250kb 용량의, 대부분의 SQL92문을 지원하는, open source RDB입니다.)) 이 wrapper를 사용하기 위해서는 (당연하게도!) sqlite3 와 (당연하게도?) boost 라이브러리가 필요합니다. 사용 예들을 살펴보는 것으로 설명을 대신합니다. 이번 글에서는 다음과 같은 contacts 테이블이 test.db에 존재한다고 가정합니다. CREATE TABLE contacts ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, phone TEXT NOT NULL, UNIQUE(name, phone) ); Command 먼저 test.db 파일을 사용하기 위해 다음과 같이 파일 이름을 주어 connection 객체를 생성합니다. 생성과 동시에 test.db와 연결이 이루어집니다. ((생성자외에 open() 함수를 사용할 수도 있습니다.)) sqlite3pp::connection conn("test.db"); 다음은 contacts 테이블에 정보를 추가하는 가장 간단한 방법입니다. connection 클래스에서 제공하는 execute 함수를 사용합니다. ((executef 함수를 사용하면 printf와 같은 문법을 사용하여 query문을 작성할 수 있습니다.)) conn.execute("INSERT INTO contacts (name, phone) VALUES ('user', '1234')"); 위와 동일한 작업을 parameterized query를 사용하여 할 수도 있습니다. ((step()함수가 실제 query문을 수행하는 함수입니다. ...

Textiler plugin test page

This post is for testing Textiler plugin . This plugin uses Textile engine (version 2.0.0). The sample text is come from Textile test page. (Note that the result will be vary according to your CSS options.) Supported wiki syntax Rendering result h2{color:green}. This is a title h3. This is a subhead p{color:red}. This is some text of dubious character. Isn't the use of "quotes" just lazy writing -- and theft of 'intellectual property' besides? I think the time has come to see a block quote. bq[fr]. This is a block quote. I'll admit it's not the most exciting block quote ever devised. Simple list: #{color:blue} one # two # three Multi-level list: # one ## aye ## bee ## see # two ## x ## y # three Mixed list: * Point one * Point two ## Step 1 ## Step 2 ## Step 3 * Point three ** Sub point 1 ** Sub point 2 Well, that went well. How about we insert an <a href="/" title="watch out">old-fashioned hypertext link</a>? Will the quo...