Working Within a File |
Now that we've enhanced our GBBopen and Common Lisp development environment, let's begin developing the random-walk application in earnest.
Create a directory to hold the random-walk application. I'm calling mine
tutorial
. Next, create a subdirectory in that directory named
source
. The reason for doing this will become clear in an
upcoming exercise. Here are the shell commands
that I used to create my directories:
[~]$ mkdir tutorial [~]$ cd tutorial [~/tutorial]$ mkdir source [~/tutorial]$
Start up a fresh Common Lisp session and load the :gbbopen-user
cl-user> :gbbopen-user
;; Loading <install-dir>/startup.lisp
...
;; Loading <install-dir>/<platform-dir>/gbbopen/gbbopen-user.fasl
gbbopen-user>
Next, begin editing a new file named tutorial-example.lisp
source
subdirectory that you just created. Even if you are more
comfortable using another editor, use the editing facilities that are provided
by your Common Lisp environment. The development features of a quality Common
Lisp environment are well worth the price of learning a new editor. In an
Emacs-based environment, such as
SLIME or Allegro
CL's ELI, typing C-x C-f
C-x C-f
^c
followed by ^f.)
Type the following two forms into the tutorial-example.lisp
(in-package :gbbopen-user) (define-unit-class location () (x y))
The in-package
in-package
The
Now, save the file.
At this point, we have been using Common Lisp's development environment, but we have not loaded the forms in our file into Common Lisp:
gbbopen-user> (make-instance 'location) Error: No class named: location. gbbopen-user>> :a gbbopen-user>
We could use Common Lisp's compile-file
load
to load the resulting compiled file. For example:
gbbopen-user> (load (compile-file "~/tutorial/source/tutorial-example.lisp"))
;; Compiling file ~/tutorial/source/tutorial-example.lisp
;; Loading ~/tutorial/source/tutorial-example.fasl
t
gbbopen-user>
but you should be able to compile and load the file directly from the editor
buffer. In SLIME, the command C-c C-k
C-c C-b
Verify that all is well by creating a location
gbbopen-user> (make-instance 'location) #<location 1> gbbopen-user>
Then delete the blackboard repository in preparation for the next exercise:
gbbopen-user> (delete-blackboard-repository) t gbbopen-user>
The GBBopen Project
Working Within a File |