Emacs/Lisp for Dr. Wyatt's Class

Running on taz

Use this document, provided by Dr. Wyatt, as a guide:
Running CMUCL on Taz
If you have any questions, please consult with Dr. Wyatt.

Fixing TRACE for recursion in CMUCL

This section was also provided by Dr. Wyatt. If you have any questions, please ask him.

By default TRACE does not work in CMUCL as you might expect. Consider, for example:
  (defun lenn (l)
    (if (endp l)
     (1+ (lenn (rest l)))))

CL-USER> (trace lenn)    ;; trace lenn

CL-USER> (lenn '(q w e r))
  0: (LENN (Q W E R))
  0: LENN returned 4

We might have wanted to see all of the tracing, including all the recursive calls.

In CMUCL, local call is used when a function defined by defun calls itself. This use of local call speeds recursion, but can also complicate debugging, since trace will only show the first call to lenn, and not the recursive calls. This is because the recursive calls directly jump to the start of the function, and don't indirect through the symbol-function. Self-recursive local call is inhibited when the :block-compile argument to compile-file is nil.

So to see all the recusive calls, try this -- where the code is in, say, hwk1.lisp:
CL-USER>  (compile-file "hwk1" :block-compile nil)  ;; compile file

CL-USER> (load *)                                   ;; load the compiled file

CL-USER> (trace lenn)                               ;; trace LENN

CL-USER> (lenn '(q w e r))                          ;; trace a call
  0: (LENN (Q W E R))
    1: (LENN (W E R))
      2: (LENN (E R))
        3: (LENN (R))
          4: (LENN NIL)
          4: LENN returned 0
        3: LENN returned 1
      2: LENN returned 2
    1: LENN returned 3
  0: LENN returned 4

Running CMUCL on your own Ubuntu Installation

This portions describes how to the install (Gnu) Emacs with the Lisp CMUCL software suitable to use in Dr. Wyatt's classes.

The target OS for the installation is:
64-bit Ubuntu 16.04 LTS Desktop
This document was last updated February 16, 2017. Virtually all aspects of the installation should go through for recent Ubuntu versions as well.


Dr. Wyatt's preferred pedagogical choice of LISP is CMUCL, which, as of the date above, provides only 32-bit version, so you'll need to install the 32-bit runtime library packages:
$ sudo apt-get install libc6-i386
Find the CMUCL tar balls you need on the release download page:
The version 21b is the one currently installed on the taz system, so we'll refer to that version for definiteness.

Look for and download these two version-based files:
From the shell, navigate to the downloads and install them in on your system within the "/usr/local" directory:
$ sudo tar xjf cmucl-21b-x86-linux.tar.bz2 -C /usr/local/
$ sudo tar xjf cmucl-21b-x86-linux.extra.tar.bz2 -C /usr/local/
This will create the following:
/usr/local/lib/cmucl/      the library files directory
/usr/local/bin/lisp        the executable file
In order to match what is expected for the EMACS installation, rename the executable:
$ cd /usr/local/bin/
$ sudo mv lisp cmucl
Confirm that cmucl is working by executing it from the shell:
$ cmucl


As of the date of this document Ubuntu uses Emacs version 24. Install it plus slime:
$ sudo apt-get install emacs slime
Emacs uses the hidden init file, ~/.emacs for personal settings. To match the taz installation, install it from here:
The ~/.Xresources provides the Emacs application default colorizations used on taz. Install it from here:
You have to log out/in to pick up the .Xresources prior to activating Emacs from the application menu.

© Robert M. Kline