3
votes

I'm reviving an old LISP program from the early 1980s. (It's the Nelson-Oppen simplifier, an early proof system. This version was part of the Ford Pascal-F Verifier, and was running in Franz LISP in 1982.) Here's the entire program:

https://github.com/John-Nagle/pasv/tree/master/src/CPC4

I'm converting the code to run under clisp on Linux, and need some advice. Most of the problems are with macros.

HUNKSHELL

Hunkshell was a 1970s Stanford SAIL hack to support records with named fields in LISP. I think I've converted this OK; it seems to work.

https://github.com/John-Nagle/pasv/blob/master/src/CPC4/hunkshell.l

The original macro generated more macros as record update functions. I'm generating defuns. Is there any reason to generate macros?

By the way, look at what I wrote for "CONCAT". Is there a better way to do that?

DEFMAC

More old SAIL macros, to make macro definition easier before defmacro became part of the language.

https://github.com/John-Nagle/pasv/blob/master/src/CPC4/defmac.l

I've been struggling with "defunobj". Here's my CL version, partly converted:

  ; This macro works just like defun, except that both the value and the
  ; function-binding of the symbol being defined are set to the function
  ; being defined.  Therefore, after (defunobj f ...), (f ...) calls the
  ; defined function, whereas f evaluates to the function itself.
  ;
(defmacro defunobj (fname args &rest b)
  `(progn 
      (defun ,fname ,args ,b)
      ;;;;(declare (special ,fname)) ;;;; ***declare not allowed here
      (setq ,fname (getd ',fname))))

If I made that declare a proclaim, would that work right? And what replaces getd to get a function pointer?

SPECIAL

There are lots of (DECLARE (SPECIAL FOO)) declarations at top level in this code. That's not allowed in CL. Is it appropriate to use (PROCLAIM (SPECIAL FOO)) instead?

1

1 Answers

3
votes

Concat

Essentially correct, but indentation is broken (like everywhere else - I suggest Emacs to fix it).

Also, you don't need the values there.

defunobj

I suggest defparameter instead of setq. Generally speaking, before setting a variable (with, e.g., setq) one should establish it (with, e.g., let or defvar).

fdefinition is what you are looking for instead of getd.

I also don't think you are using backquote right:

(defmacro defunobj (fname &body body)
  `(progn 
     (defun ,fname ,@body)
     (defparameter ,fname (fdefinition ',fname))))

Special

I think defvar and defparameter are better than proclaim special.

PS. Are you aware of the CR.se site?