Date: Mon, 11 Nov 1996 17:26:01 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Sun, 01 Sep 1996 06:41:27 GMT Content-length: 9724
Since GCL has the same prompt as the default UNIX prompt on the workstations, you might want to change the UNIX prompt to be something else. To do this, run the shell command (you can put this command in your ".cshrc.local" file to avoid doing it every time):
set prompt=whatever-you-like
>(help) ;; introductory help message >(help symbol) ;; documentation on everything ;; associated with symbol. E.g., (help 'load) >(help 'step) >(help 'trace) >(help 'compile-file) >(help 'dribble) >(help 'any-Lisp-function-that-you-are-interested-in) >(help* string) ;; documentation on all symbols ;; containing string as a sub-string. E.g., ;; (help* "remove") describes the functions remove, ;; remove-if, remove-duplicates, and remove-if-not >(apropos string) ;; like help*, except only lists the names >(documentation symbol type) ;; prints online ;; documentation string for the symbol of the given type, if ;; available.
You can also use GNU's info facility to access documentation. A WWW version is available; in addition, this material may be accessed by the UNIX program info (type info at the UNIX prompt) or within Emacs (by typing "ESC-x info").
UNIX> vi my-functions.lisp (defun welcome () (format t "Hello! Welcome."))
:se ai sm lisp
or to have these settings set every time you enter vi, just edit the .exrc file in your home directory to include the line:
set ai sm lisp
Finally, there is also an operator in vi that realigns existing lines as though they had been typed in with lisp and autoindent set. This is the = operator. Using the command =% at the beginning of a function will realign all of the lines in that function. See also the use of the (,),{, }, [[ and ]] commands for moving around within Lisp functions. Here is a brief explanation to help you try them out. The ( and ) commands move backward and forward over s-expressions. The { and } commands are like ( and ) but don't stop at atoms. These can be used to skip to the next list, or through a comment quickly. The [[ and ]] commands advance and retreat to lines beginning with a (. They are useful for dealing with entire function definitions.
As an alternative to keeping separate windows for vi and GCL, we can define a Lisp function "vi" which will allow us to call vi from within GCL, and automatically load the changes when we're done editing. To do this, save the contents of ~dyer/public/html/cs540/lisp-vi.lisp in a file in your own directory, and load that file into GCL.
>(load "my-functions.lisp")
While GCL is loading all of the functions in this file it does some simple syntax checking such as unmatched parentheses and misused punctuation. Your functions will not be loaded successfully if it has any of these syntax errors. In this case, go back to the vi window, edit your functions, and then reload the file in the GCL window.
>(welcome) Hello! Welcome.
If there are any runtime errors, use vi in the other window to modify your program, and then, in the GCL window, reload the file containing the program and run it again.
>(compile-file "my-functions.lisp") >(load "my-functions.o") >(welcome)
After compiling, an executable file my-functions.o is created in your current directory. Debug your program using the interpreter first, and compile for the optimized executable code only when everything is debugged.
One way is to use dribble:
>(dribble file-name-given-as-a-string) ;; start typescript Run programs here plus anything else you want saved >(dribble) ;; stop typescript
Everything displayed on the screen will be saved in the given file including both what you type and what the Lisp interpreter responds.
You can also use the UNIX command script filename before starting GCL, with the UNIX command exit after ending the GCL session. This appears to give slightly better looking output.
>(trace func-name) ;; trace named function >(untrace func-name) ;; stop tracing named function >(step (func-name parameters-if-any)) ;; single-step mode
>(bye) ;; Control-d will also stop GCL
Lisp invokes a "break package" whenever it encounters an error or the
user aborts execution. The break package is recognizable as the
prompt changes from '>' to '>>'. There are many options for you to
choose in this package:
Break-loop Command Summary ([] indicates optional arg)
:help this summary :bl [j] show local variables and their values, or segment of vs if compiled in j stack frames starting at the current one :bt [n] BACKTRACE [n steps] :down [i] DOWN i frames (one if no i) :env describe ENVIRONMENT of this stack frame (for interpreted). :fr [n] show frame n :loc [i] return i'th local of this frame if its function is compiled (si::loc i) :r RESUME (return from the current break loop) :up [i] UP i frames (one if no i) Example: print a backtrace of the last 4 frames >>:bt 4 Note: (use-fast-links nil) makes all non system function calls be recorded in the stack. (use-fast-links t) is the default Low level commands: ------------------ :p [i] make current the i'th PREVIOUS frame (in list show by :b) :n [i] make current the i'th NEXT frame (in list show by :b) :go [ihs-index] make current the frame corresponding to ihs-index :m print the last break message :c show function of the current ihs frame :q [i] quit to top level :r resume from this break loop :b full backtrace of all functions and special forms :bs [name] backward search for frame named 'name' :fs [name] search for frame named 'name' :vs [from] [to] Show value stack between FROM and TO :ihs [from] [to] Show Invocation History Stack :bds ['v1 'v2 ..]Show previous special bindings of v1, v2,.. or all if no v1