Hi all,
I'm really enjoying Land of Lisp!
I can understand Conrad not wanting to complicate the book with all
the many details around source files, editing, editor configuration,
etc. Paul Graham, as I recall, says he uses two terminal windows, one
with a REPL, the other with the vi editor. For beginners, that's not
a bad way to go, maybe substituting your favorite editor for vi. Be
sure to pick an editor that can help you with balancing parentheses.
I've always used emacs, and got somewhat used to slime during my last
fling with Common Lisp. For what it's worth, here's how I set myself
up for Land of Lisp on my Mac:
1) I've had macports installed forever, and used it to install CLISP.
1.5) I sometimes use the terminal-only emacs that ships with Mac OS
X, but also like Aquamacs, which I think I installed via binary
download.
2) I had previously used quicklisp (a new package manager for lisp
that aspires to be CPAM for common lisp -- see quicklisp.org) with
SBCL. I couldn't quickly figure out how to easily switch between lisp
implementations in quicklisp, so I just wiped it out and installed it
all over again with CLISP.
3) I followed the directions in the quicklisp.org FAQ to install
slime.
4) I Made a working directory for my landoflisp stuff, and initialized
it as a git repo.
5) Created adv.lisp and started typing in the code for the wizard's
text adventure game.
Problem: You can have slime tell clisp to compile the last symbolic
expression (complete lisp "form" with balanced parentheses) with the c-
x c-e (control-x control-e) keystroke. I like to do that as I type in
the source, so I catch mistakes early. The trouble was that when I
switched from the adv.lisp buffer to the "slime-repl clisp" buffer,
nothing I had complied was available.
Solution: Conrad (wisely) doesn't seem to cover packages, but I
suspect that the lisp package you are in when you type c-x c-e in a
file buffer doesn't match the default package in the slime repl
buffer. I solved my problem by putting these lines at the top of
adv.lisp:
(defpackage #:adventure
(:use #:cl))
(in-package #:adventure)
(defparameter *nodes* ...
I then used c-x c-e on every s-expression again (there's a keystroke
for compiling the whole buffer, but I was too impatient to look it
up ;-)
Back in the slime repl, I typed (in-package #:adventure), and now
*nodes* and everything else was available.
Packages are lisp's version of modules or namespaces from other
languages, so the above first defined a package for the adventure
game, and then declared that the following code should go in the new
package. Similarly, the in-package statement in the repl put me into
the adventure package namespace so the parameters, functions, and so
on would be available.
I'm basically an advanced beginner in common lisp, so better answers
from real lispers would be very welcome.