PC-LISP is an implementation of the
Franz Lisp
In computer programming, Franz Lisp is a discontinued Lisp programming language system written at the University of California, Berkeley (UC Berkeley, UCB) by Professor Richard Fateman and several students, based largely on Maclisp and distribu ...
dialect by Peter Ashwood-Smith.
Version 2.11 was released on May 15, 1986. A current version may be downloaded from the external link below.
Currently, PC-LISP has been ported to 32 & 64 bit Linux, Mac, and Windows.
Note that the Franz LISP dialect was the immediate, portable successor to the
ITS version of
Maclisp and is perhaps the closest thing to the LISP in the
Steven Levy
Steven Levy (born 1951) is an American journalist and Editor at Large for ''Wired'' who has written extensively for publications on computers, technology, cryptography, the internet, cybersecurity, and privacy. He is the author of the 1984 book ...
book ''
Hackers
A hacker is a person skilled in information technology who uses their technical knowledge to achieve a goal or overcome an obstacle, within a computerized system by non-standard means. Though the term ''hacker'' has become associated in popu ...
'' as is practical to operate. PC-LISP runs well in DOS emulators and on modern Windows versions. Because PC-LISP implements Franz LISP, it is a dynamically scoped predecessor to modern
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ''ANSI INCITS 226-1994 (S20018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived fro ...
. This is therefore an historically important implementation.
Example
The session is running the following code which demonstrates
dynamic scoping
In computer programming, the scope of a name binding (an association of a name to an entity, such as a variable) is the part of a program where the name binding is valid; that is, where the name can be used to refer to the entity. In other parts o ...
in Franz LISP. Note that PC-LISP does not implement the
let
special form that
Emacs Lisp
Emacs Lisp is a dialect of the Lisp programming language used as a scripting language by Emacs (a text editor family most commonly associated with GNU Emacs and XEmacs). It is used for implementing most of the editing functionality built into Ema ...
provides for local variables. Instead, all variables are what an
ALGOL
ALGOL (; short for "Algorithmic Language") is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by the ...
-based language would call "global". The first dialect of Lisp to incorporate ALGOL scoping rules (called
lexical scoping
In computer programming, the scope of a name binding (an association of a name to an entity, such as a variable) is the part of a program where the name binding is valid; that is, where the name can be used to refer to the entity. In other parts o ...
) was
Scheme A scheme is a systematic plan for the implementation of a certain idea.
Scheme or schemer may refer to:
Arts and entertainment
* ''The Scheme'' (TV series), a BBC Scotland documentary series
* The Scheme (band), an English pop band
* ''The Schem ...
although the
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ''ANSI INCITS 226-1994 (S20018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived fro ...
language also added this feature.
;; Demonstration of dynamic scoping
;; This is a "global" variable
(setq myglobal "this is my global variable")
;; Another global variable
(setq yourglobal "this is my global variable")
;; a function which prints the symbols
(defun dosomething (mine yours)
(princ " * Mine is - ")
(princ mine)
(princ "\n")
(princ " * Yours is - ")
(princ yours)
(princ "\n"))
;; override the symbols
(defun nolocals ()
(setq mine "I have set mine to a new value")
(setq yours "I have set yours to a new value")
(dosomething mine yours))
(defun main ()
;; define two symbols
(setq mine myglobal)
(setq yours yourglobal)
;; print them
(princ "calling dosomething\n")
(dosomething mine yours)
(princ "calling nolocals\n")
(nolocals)
(princ "calling dosomething again\n")
(dosomething mine yours))
Another example showing the use of backquote and the power of LISP. This is a differentiation example.
; D(e,X) -
; Will compute the symbolic derivative of expression e with respect
; to variable X. We take the expression in standard lisp prefix form and will
; use the following rules of differentiation.
;
; D(x) = 1
; D(a) = 0
; D(ln u) = D(u)/u
; D(u+v) = D(u)+D(v)
; D(u-v) = D(u)-D(v)
; D(u*v) = D(u)*v + u*D(v)
; D(u/v) = D(u)*v + (u*D(v))/v^2
; D(v^u) = (v^u)*(u*D(v)/v + D(u)*ln(v))
;
(defun D(e X &aux u v)
(cond ((equal e X) 1)
((atom e) 0)
(t (setq u (cadr e) v (caddr e))
(caseq (car e)
(ln `(/ ,(D u X) ,u))
(+ `(+ ,(D u X) ,(D v X)))
(- `(- ,(D u X) ,(D v X)))
(* `(+ (* ,(D u X) ,v) (* ,(D v X) ,u)))
(/ `(- (/ ,(D u X) ,v)
(/ (* ,u ,(D v X)) (^ ,v 2))))
(^ `(* ,e (+ (/ (* ,v ,(D u X)) ,u)
(* ,(D v X) (ln ,u)))))
(t (princ "ERROR") (exit)]
References
{{reflist
External links
PC-LISP github
Lisp programming language family
Discontinued development tools