diff --git a/README.md b/README.md index 190505d..31efe93 100644 --- a/README.md +++ b/README.md @@ -2,31 +2,33 @@ LISP 1.5 is to all Lisp dialects as Beowulf is to Emglish literature. +## What this is + +A work-in-progress towards an implementation of Lisp 1.5 in Clojure. + +## BUT WHY?!!?! + +Because. + +Because Lisp is the only computer language worth learning, and if a thing is worth learning, it's worth learning properly; which means going back to the beginning and trying to understand that. + +Because there is, so far as I know, no working implementation of Lisp 1.5 for modern machines. + +Because I'm barking mad, and this is therapy. + ## Installation Download from http://example.com/FIXME. ## Usage -FIXME: explanation +`java -jar beowulf-0.1.0-standalone.jar` - $ java -jar beowulf-0.1.0-standalone.jar [args] +## Learning Lisp 1.5 -## Options - -FIXME: listing of options this app accepts. - -## Examples - -... - -### Bugs - -... - -### Any Other Sections -### That You Think -### Might be Useful +The `Lisp 1.5 Programmer's Manual` is still +[in print, ISBN 13 978-0-262-13011-0](https://mitpress.mit.edu/books/lisp-15-programmers-manual); but it's also +[available online](http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf). ## License diff --git a/src/beowulf/cons_cell.clj b/src/beowulf/cons_cell.clj index b54a915..8139bc4 100644 --- a/src/beowulf/cons_cell.clj +++ b/src/beowulf/cons_cell.clj @@ -3,7 +3,24 @@ (def NIL (symbol "NIL")) -(deftype ConsCell [CAR CDR]) +(deftype ConsCell [CAR CDR] + clojure.lang.ISeq + (cons [this x] (ConsCell. x this)) + (count [this] (if + (= (.CDR this) NIL) + 0 + (inc (count (.CDR this))))) + (first [this] (.CAR this)) + (more [this] (if + (= (.CDR this) NIL) + clojure.lang.PersistentList/EMPTY + (.CDR this))) + (next [this] (.CDR this)) + (seq [this] this) ;; doesn't work - `Method beowulf/cons_cell/ConsCell.seq()Lclojure/lang/ISeq; is abstract` + + clojure.lang.IPersistentCollection + (empty [this] false) + (equiv [this other] false)) (defn make-cons-cell [a d] diff --git a/src/beowulf/eval.clj b/src/beowulf/eval.clj new file mode 100644 index 0000000..22afe71 --- /dev/null +++ b/src/beowulf/eval.clj @@ -0,0 +1,25 @@ +(ns beowulf.eval + (:require [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell NIL]])) + +(declare *oblist* primitive-eval) + + + +(defn primitive-eval + [x] + (cond + (number? x) x + (symbol? x) (@*oblist* x) + (instance? x beowulf.cons_cell.ConsCell) + (apply (primitive-eval (.CAR x)) (map primitive-eval (.CDR x))) + :else + (throw (Exception. (str "Don't know how to eval `" x "`"))))) + + +(def ^:dynamic *oblist* + "The base environment." + (atom {'NIL NIL + 'F NIL + 'T 'T + 'eval primitive-eval})) +