Programming Assignment 1: Lisp
We have provided the code to get you started. Follow the below steps
to get the code and start it running.
- Step 1: Copy the sample code.
All you will need is a loader
file and the sample program that demonstrates the basic functionality.
Copy /usr/class/cs157/lisp/sample/loader.lisp and
/usr/class/cs157/lisp/sample/example.lisp.
Please note that the instructions, code, and support we are providing
are only tested on the leland Solaris machines.
- Step 2: Load the code.
Log in to one of the Leland machines
that have alisp installed, e.g. the elaine's or saga's.
From the directory to which you just
copied loader.lisp and example.lisp, run
alisp. (The first time you run it, it may take a while to load.)
At the prompt, enter (load "loader.lisp"). A bunch of
warnings and output will fly by. Ignore the warnings.
- Step 3: Start the webserver.
-
Choose a random port number in the range 5000-65000. This will bind your
server application to that port for the machine on which you're running
your server. Try to choose a random number and remember it - you will be
the only person on that machine who can use that port, and you will need
it to have access over the Web.
- Enter the command
(startserver 5000), where 5000 is an example of a port in
the range 5000-65000. The response from Lisp will be a message
that it is listening on port 5000. If you press Enter, you will
get the prompt back.
- Step 4: Access the webserver.
Your automated reasoner will be accessible from the Web at the address
http://<machineXX>:<portnum>/, where
<machineXX>
refers to the Solaris machine from which you're running the Web
server (e.g., saga22, elaine45,
etc.) and
<portnum> is the port you gave to startserver.
If you were using
elaine28 and port 5000, the URL would be http://elaine28:5000/.
Now the webserver should be up and running. The sample does nothing even
remotely interesting, but the code is there to get you started.
Once you
make changes to the Lisp code, you need only reload the affected files--with
one exception. If you make changes to the function myfrontpage,
you will need to reload at least one of the files mentioned in
loader.lisp, so it is easiest to reload them all. You can
even reload files without shutting down the webserver.
Shutting down the webserver is easy. It should be shut down
automatically when you exit the alisp from which the server was started.
But if you want to kill the server without exiting alisp,
in the terminal window from which you started the webserver,
execute (stopserver). Lisp returns NIL and shuts down
the server process.
Now a few notes on Lisp and alisp.
- If for some reason you need to stop alisp in the middle of execution,
you can use Control-C. alisp will give you a restart menu which includes
a list of Restart actions. If you simply want to kill the process,
choose the Return to Top Level (an "abort" restart) option.
(It is usually the second option from the bottom.) Say the abort
restart option is number 1; then type :cont 1. (Don't
forget the colon.)
- Executing Lisp functions on the command line will always look the
same as standard Lisp, as in example.lisp, e.g. (startserver 5000).
Executing alisp-specific commands on the command line
requires a slightly different syntax. You've
already seen one example :cont 1. These alisp commands
start with a colon (:) followed by the command and the arguments to that
command. :help gives you a listing of these commands.
:exit quits out of alisp.
- The command line doesn't care about white-space. All the below are
equivalent:
- (startserver 5000)
- (startserver 5000
)
- (
startserver
5000
)
This means that if you enter a command that is missing a right parenthesis
and press Enter, alisp thinks you are still in the midst of entering a
command. It will just sit there and wait.
- If you get lost in a bunch of errors, you can always do an abort
restart (it will almost always be the second restart option from the bottom).
The last restart option will quit out of Alisp.
- Here's a Lisp Primer.
Here's the
Common Lisp Specification
Here's a site all
about Lisp and tutorials
If none of these suit you, try googling "lisp tutorial"
(c) Copyright 1995-2004 by
Michael Genesereth