Getting Started with CLISP

Many great Lisp compilers are available, but one in particular is easiest to get started with: CLISP, an open source Common Lisp. CLISP is simple to install and runs on any operating system.

Other popular Lisps include Steel Bank Common Lisp (SBCL), a fast Common Lisp that’s considered a bit more heavy-duty than CLISP and also open source; Allegro Common Lisp, a powerful commercial Lisp by Franz, Inc; LispWorks; Clozure CL; and CMUCL. Mac users may want to consider LispWorks or Clozure CL, which will be easier to get running on their machines. However, for our purposes, CLISP is the best choice.

Note

Starting with Chapter 12, we’ll be using some CLISP-specific commands that are considered nonstandard. However, up until that point, any implementation of Common Lisp will work for running the examples in this book.

Installing CLISP

You can download a CLISP installer from http://clisp.cons.org/. It will run on Windows PCs, Macs, and Linux variants. On a Windows PC, you simply run an install program. On a Mac, there are some additional steps, which are detailed on the website.

On a Debian-based Linux machine, you should find that CLISP already exists in your standard sources. Just type apt-get install clisp at the command line, and you’ll have CLISP installed automatically.

For other Linux distributions (Fedora, SUSE, and so on), you can use standard packages listed under “Linux packages” on the CLISP website. And experienced Linux users can compile CLISP from source.

Starting Up CLISP

To run CLISP, type clisp from your command line. If all goes according to plan, you’ll see the following prompt:

$ clisp
  i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  I I I I I I I      8     8   8           8     8     o  8    8
  I   `+' /  I      8         8           8     8        8    8
     `-+-'  /       8         8           8      ooooo   8oooo
    `-__|__-'        8         8           8           8  8
        |            8     o   8           8     o     8  8
  ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2006

[1]>

Like all Common Lisp environments, CLISP will automatically place you into a read-eval-print loop (REPL) after you start it up. This means you can immediately start typing in Lisp code.

Try it out by typing (+ 3 (* 2 4)). You’ll see the result printed below the expression:

[1]> (+ 3 (* 2 4))
11

This shows how the REPL works. You type in an expression, and then the Lisp will immediately evaluate it and return the resulting value. When you want to shut down CLISP, just type (quit).

Now that you have CLISP working on your computer, you’re ready to write a Lisp game!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.180.43