PC-LISP

{{Multiple issues|{{More citations needed|date=November 2024}}

{{Notability|date=September 2023}}}}{{Infobox programming language

| name = PC-LISP

| developer = Peter Ashwood-Smith

| influenced by = Franz Lisp

| platform = i386, x86-64

| operating system = Linux, macOS, Microsoft Windows, NetBSD

| license = {{ubl|BSD-2-Clause license|historically: Shareware}}

}}

PC-LISP is an implementation of the Franz Lisp dialect by Peter Ashwood-Smith.{{Cite web |last=Ashwood-Smith |first=Peter |date=1 February 1990 |title=PC-LISP V3.00 (C) February 1st 1990 Peter Ashwood-Smith |url=https://www.cs.cmu.edu/Groups/AI/lang/others/franzlsp/pclisp/readme.txt |access-date=14 November 2024 |website=Carnegie Mellon University - School of Computer Science}}{{Cite web |date=4 August 2020 |title=blakemcbride/PC-LISP |url=https://github.com/blakemcbride/PC-LISP |access-date=14 November 2024 |via=GitHub}}{{Cite magazine |last=Ashwood-Smith |first=Peter |date=May 1987 |editor-last=Van Deusen |editor-first=Mary S. |title=PC-LISP |url=https://www.iment.com/maida/computer/lisp-ptrs/lp-i.1.51-2.htm |access-date=14 November 2024 |magazine=LISP Pointers |pages=51-52 |volume=1 |issue=1}}

Version 2.07 was released on 1 February 1986,{{Cite web |last=Ashwood-Smith |first=Peter |date=20 February 1986 |title=A GUIDE TO THE PC-LISP INTERPRETER (V2.07) |url=https://www.tuhs.org/Usenet/comp.sources.unix/1986-February/003454.html |access-date=14 November 2024 |website=The Unix Heritage Society}} and version 3.00 was released on 1 February 1990. A current version is available through GitHub.

Currently, PC-LISP has been ported to 32 & 64 bit versions of Linux, Mac, Windows and NetBSD.{{Cite web |title=lang/pc-lisp - The NetBSD Packages Collection |url=https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/pc-lisp/index.html |access-date=14 November 2024 |website=NetBSD}} For NetBSD there also exists ports for AArch64, ARMv5/6/7, PowerPC, Motorola 68000, SPARC/SPARC64, Alpha and VAX.

Note that the Franz LISP dialect was the immediate, portable successor to the ITS version of Maclisp{{Cite manual |last=Foderaro |first=John K. |url=https://github.com/blakemcbride/PC-LISP/blob/master/Franz_Lisp_July_1983.pdf |title=The FRANZ LISP Manual |last2=Sklower |first2=Keith L. |last3=Layer |first3=Kevin |date=June 1983 |pages=5 |chapter=FRANZ LISP |via=GitHub}} and is perhaps the closest thing to the LISP in the Steven Levy book Hackers as is practical to operate.{{Citation needed|date=November 2024}}

PC-LISP is written primarily in the C programming language, with some parts now also written in Common Lisp. 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. This is therefore an historically important implementation.

Example

The session is running the following code which demonstrates dynamic scoping in Franz LISP. Note that PC-LISP does not implement the let special form that Emacs Lisp provides for local variables. Instead, all variables are what an ALGOL-based language would call "global". The first dialect of Lisp to incorporate ALGOL scoping rules (called lexical scoping) was Scheme although the Common Lisp language also added this feature.{{Citation needed|date=November 2024}}

;; 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.{{Citation needed|date=November 2024}}

; 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}}