Tips on using Allegro Common Lisp

All basic commands to Allegro are keywords proceeded by a colon ":" and followed by arguments that do not need to be quoted.

Aborting an error

If an error occurs, the Lisp interpreter will invoke the "break package" with error message and a different prompt. To simply exit from the error, type ":res" for "resume" and it will abort the run and return to the top-level prompt. For example:

USER(1): (rest 3)
Error: Attempt to take the cdr of 3 which is not listp.
  [condition type: SIMPLE-ERROR]
[1] USER(2): :res
USER(3): 

Aborting a run

If the program is running too long (e.g. caught in an infinite loop) or if you simply want to terminate execution, type "C-c C-c" (two control C's in succession) to abort. It may take a while for Lisp to notice your interupt, so be patient after you type the abort command and it should eventually terminate.

USER(5): (factorial 100000)      ;Comment: typed C-c C-c after a bit....
Error: Received signal number 2 (Keyboard interrupt)
  [condition type: INTERRUPT-SIGNAL]

Restart actions (select using :continue):
 0: continue computation
[1] USER(6): :res
USER(7): 

Compiling and loading a file

The command ":cl" followed by the name of a file (no quotes, no need to include the .lisp extension) will compile and load a Lisp file. The command ":ld" will simply load a file, prefering the compiled version if there is one.

USER(8): :cl factorial
;;; Compiling file factorial.lisp
; Compiling FACTORIAL
;  Note: tail merging call to EXCL::*_2OP
;;; Writing fasl file factorial.fasl
Warning: No IN-PACKAGE form seen in factorial.lisp.  (Allegro Presto will be ineffective when loading a file having no
         IN-PACKAGE form.)
;;; Fasl write complete
; Fast loading factorial.fasl      ;Comment: name of file created with compiled code
USER(9): (factorial 4)
24

Changing the directory

The command ":cd" changes the current working directory. ":pwd" prints the current working directory.

USER(15): :cd cs351-code
cs351-code/
USER(16): :pwd
Lisp's current working directory is "/v/hank/v43/mooney/cs351-code/"
*default-pathname-defaults* is #p""

Exiting Lisp

To terminate the Lisp system, use the command ":exit" or call the function "(exit)."

USER(3): :exit
; killing "Editor Server"
; killing "Run Bar Process"
; killing "Listener Socket Daemon"
; killing "Initial Lisp Listener"
; Exiting Lisp

If you are using Allegro under Emacs, you can then kill the buffer using the Emacs command "C-x k"

Editing commands in the buffer

While typing an expression to evaluate, you can edit it with normal Emacs commands. In addition, you can recover and edit previous ones using "C-c C-p" (repeatedly) to get previous commands, and "C-c C-n" (repeatedly) to get next ones.

Editing Lisp program files

If you load ACL in Emacs first and name files with the extension ".lisp", they should be recognized and put in Emacs Common Lisp mode when you open them. If this ever fails, you can enter the mode manually by typing M-x to enter an Emacs command in the mini-buffer at the bottom and typing common-lisp-mode at the prompt. In this mode, programs should be indented automatically as you type them in (by automatically spacing over after you hit return). Use C-M-q, (Hold the CONTROL and META keys while depressing the q key) when the point is on an opening parenthesis, to reindent a complete expression.

Using the Debugger

See the list of debugger commands by typing ":help" in a break. Particularly useful is ":zo" which will show a trace of calls on the stack.
[1] USER(15): :zo
Evaluation stack:

   (ERROR TYPE-ERROR :DATUM ...)
 ->(APPEND . 2)
   (FACTORIAL 0)
   (FACTORIAL 1)
   (FACTORIAL 2)
   (FACTORIAL 3)
   (FACTORIAL 4)
   (FACTORIAL 5)
   (FACTORIAL 6)

... more older frames ...
If you start Allegro "composer" from the Emacs menu item "Composer" that Allegro adds, you can then call the window debugger using ":wdebug".
[1] USER(17): :wdebug  

Bringing up a window debugger for #MULTIPROCESSING:PROCESS
                                    Initial Lisp Listener @ #x8081d4a...
Window debugger is now active.
The window debugger allows you to examine and manipulate the calling stack in various ways. Right-click in the left margin of a frame to bring up a menu of commands for this frame, or right-click on a function name or argument to bring up a menu of options for that item.

The commands ":dn" and ":up:" will move your current position up and down the stack. The command ":local var-name" will show you the value of the local variable var-name at the current point in the stack. For example:

USER(14): (defun factorial (x)
		 (if (zerop x)
		     nil
		   (* x (factorial (- x 1)))))
FACTORIAL
USER(15): (factorial 10)
Error: `NIL' is not of the expected type `NUMBER'
  [condition type: TYPE-ERROR]

Restart actions (select using :continue):
 0: Return to Debug Level 1 (an "abort" restart)
 1: continue computation
 2: Return to Top Level (an "abort" restart)
[1] USER(16): :zo
Evaluation stack:

   (ERROR TYPE-ERROR :DATUM ...)
 ->(* 1 NIL)
   (FACTORIAL 1)
   (FACTORIAL 2)
   (FACTORIAL 3)
   (FACTORIAL 4)
   (FACTORIAL 5)
   (FACTORIAL 6)
   (FACTORIAL 7)

... more older frames ...
[1] USER(17): :local x
1
1
[1] USER(18): :dn
Evaluation stack:

   (ERROR TYPE-ERROR :DATUM ...)
   (* 1 NIL)
 ->(FACTORIAL 1)
   (FACTORIAL 2)
   (FACTORIAL 3)
   (FACTORIAL 4)
   (FACTORIAL 5)
   (FACTORIAL 6)
   (FACTORIAL 7)

... more older frames ...
[1] USER(19): :dn
Evaluation stack:

   (ERROR TYPE-ERROR :DATUM ...)
   (* 1 NIL)
   (FACTORIAL 1)
 ->(FACTORIAL 2)
   (FACTORIAL 3)
   (FACTORIAL 4)
   (FACTORIAL 5)
   (FACTORIAL 6)
   (FACTORIAL 7)

... more older frames ...
[1] USER(20): :dn
Evaluation stack:

... 1 more (possibly invisible) newer frame ...

   (ERROR TYPE-ERROR :DATUM ...)
   (* 1 NIL)
   (FACTORIAL 1)
   (FACTORIAL 2)
 ->(FACTORIAL 3)
   (FACTORIAL 4)
   (FACTORIAL 5)
   (FACTORIAL 6)
   (FACTORIAL 7)

... more older frames ...
[1] USER(21): :local x
3
3

ACL Emacs menus

Peruse the items under the menus that ACL adds to Emacs. The various loading and compiling options under ACLFile are useful when editing a Lisp file. The various options under ACLHelp, particularly Arglist, are useful for obtaining information when calling or writing functions.