diff --git a/README.md b/README.md
index 430ce62..364cfe3 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ LISP 1.5 is to all Lisp dialects as Beowulf is to English literature.
A work-in-progress towards an implementation of Lisp 1.5 in Clojure. The
objective is to build a complete and accurate implementation of Lisp 1.5
as described in the manual, with, in so far as is possible, exactly the
-same behaviour — except as documented below.
+same bahaviour - except as documented below.
### BUT WHY?!!?!
@@ -62,11 +62,14 @@ Working Lisp interpreter, but some key features not yet implemented.
### Project Target
-The project target is to be able to run the [Wang algorithm for the propositional calculus](https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=52) given in chapter 8 of the *Lisp 1.5 Programmer's Manual*. When that runs, the project is as far as I am concerned feature complete. I may keep tinkering with it after that and I'll certainly accept pull requests which are in the spirit of the project (i.e. making Beowulf more usable, and/or implementing parts of Lisp 1.5 which I have not implemented), but this isn't intended to be a new language for doing real work; it's an educational and archaeological project, not serious engineering.
+The project target is to be able to run the [Wang algorithm for the propositional calculus](https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=52) given in chapter 8 of the *Lisp 1.5 Programmer's Manual*. When that runs, the project is as far as I am concerned feature complete. I may keep tinkering with it after that and I'll certainly accept pull requests which are in the spirit of the project (i.e. making Beowulf more usable, and/or implementing parts of Lisp 1.5 which I have not implemented), but this isn't intended to be a new language for doing real work; it's an
+educational and archaeological project, not serious engineering.
-Some `readline`-like functionality would be really useful, but my attempt to integrate [JLine](https://github.com/jline/jline3) has not (yet) been successful.
+Some `readline`-like functionality would be really useful, but my attempt to
+integrate [JLine](https://github.com/jline/jline3) has not (yet) been successful.
-An in-core structure editor would be an extremely nice thing, and I may well implement one.
+An in-core structure editor would be an extremely nice thing, and I may well
+implement one.
You are of course welcome to fork the project and do whatever you like with it!
@@ -107,53 +110,53 @@ now be possible to reimplement them as `FEXPRs` and so the reader macro function
| Function | Type | Signature | Implementation | Documentation |
|--------------|----------------|------------------|----------------|----------------------|
-| NIL | Lisp variable | ? | | The canonical empty list. See manual pages 22, 69s |
-| T | Lisp variable | ? | | The canonical true value. See manual pages 22, 69 |
-| F | Lisp variable | ? | | The canonical false value. See manual pages 22, 69 |
-| ADD1 | Host lambda function | x:number | | Add one to the number `x`. |
-| AND | Host lambda function | expr* | PREDICATE | `T` if and only if none of my `args` evaluate to either `F` or `NIL`, else `F`.
In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
-| APPEND | Lisp lambda function | ? | | see manual pages 11, 61 |
-| APPLY | Host lambda function | ? | | Apply this `function` to these `arguments` in this `environment` and return the result.
For bootstrapping, at least, a version of APPLY written in Clojure.
All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects.
See page 13 of the Lisp 1.5 Programmers Manual. |
-| ASSOC | Lisp lambda function, Host lambda function | a:list | ? | If a is an association list such as the one formed by PAIRLIS in the above example, then assoc will produce the first pair whose first term is x. Thus it is a table searching function. All args are assumed to be `beowulf.cons-cell/ConsCell` objects. See page 12 of the Lisp 1.5 Programmers Manual.
**NOTE THAT** this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. |
-| ATOM | Host lambda function | x:expr | PREDICATE | Returns `T` if and only if the argument `x` is bound to an atom; else `F`. It is not clear to me from the documentation whether `(ATOM 7)` should return `T` or `F`. I'm going to assume `T`. |
-| CAR | Host lambda function | list | | Return the item indicated by the first pointer of a pair. NIL is treated specially: the CAR of NIL is NIL. |
-| CAAAAR | Lisp lambda function | list | ? | ? |
-| CAAADR | Lisp lambda function | list | ? | ? |
-| CAAAR | Lisp lambda function | list | ? | ? |
-| CAADAR | Lisp lambda function | list | ? | ? |
-| CAADDR | Lisp lambda function | list | ? | ? |
-| CAADR | Lisp lambda function | list | ? | ? |
-| CAAR | Lisp lambda function | list | ? | ? |
-| CADAAR | Lisp lambda function | list | ? | ? |
-| CADADR | Lisp lambda function | list | ? | ? |
-| CADAR | Lisp lambda function | list | ? | ? |
-| CADDAR | Lisp lambda function | list | ? | ? |
-| CADDDR | Lisp lambda function | list | ? | ? |
-| CADDR | Lisp lambda function | list | ? | ? |
-| CADR | Lisp lambda function | list | ? | ? |
-| CDAAAR | Lisp lambda function | list | ? | ? |
-| CDAADR | Lisp lambda function | list | ? | ? |
-| CDAAR | Lisp lambda function | list | ? | ? |
-| CDADAR | Lisp lambda function | list | ? | ? |
-| CDADDR | Lisp lambda function | list | ? | ? |
-| CDADR | Lisp lambda function | list | ? | ? |
-| CDAR | Lisp lambda function | list | ? | ? |
-| CDDAAR | Lisp lambda function | list | ? | ? |
-| CDDADR | Lisp lambda function | list | ? | ? |
-| CDDAR | Lisp lambda function | list | ? | ? |
-| CDDDAR | Lisp lambda function | list | ? | ? |
-| CDDDDR | Lisp lambda function | list | ? | ? |
-| CDDDR | Lisp lambda function | list | ? | ? |
-| CDDR | Lisp lambda function | list | ? | ? |
-| CDR | Host lambda function | list | | Return the item indicated by the second pointer of a pair. NIL is treated specially: the CDR of NIL is NIL. |
-| CONS | Host lambda function | expr, expr | | Construct a new instance of cons cell with this `car` and `cdr`. |
-| CONSP | Host lambda function | o:expr | ? | Return `T` if object `o` is a cons cell, else `F`.
**NOTE THAT** this is an extension function, not available in strict mode. I believe that Lisp 1.5 did not have any mechanism for testing whether an argument was, or was not, a cons cell. |
-| COPY | Lisp lambda function | ? | | see manual pages 62 |
-| DEFINE | Host lambda function | ? | PSEUDO-FUNCTION | Bootstrap-only version of `DEFINE` which, post boostrap, can be overwritten in LISP. The single argument to `DEFINE` should be an association list of symbols to lambda functions. See page 58 of the manual. |
-| DIFFERENCE | Host lambda function | x:number, y:number | | Returns the result of subtracting the number `y` from the number `x` |
-| DIVIDE | Lisp lambda function | x:number, y:number | | see manual pages 26, 64 |
-| DOC | Host lambda function | ? | ? | Open the page for this `symbol` in the Lisp 1.5 manual, if known, in the default web browser.
**NOTE THAT** this is an extension function, not available in strct mode. |
-| EFFACE | Lisp lambda function | ? | PSEUDO-FUNCTION | see manual pages 63 |
+| NIL | Lisp variable | ? | | see manual pages 22, 69 |
+| T | Lisp variable | ? | | see manual pages 22, 69 |
+| F | Lisp variable | ? | | see manual pages 22, 69 |
+| ADD1 | Host lambda function | ? | | ? |
+| AND | Host lambda function | ? | PREDICATE | `T` if and only if none of my `args` evaluate to either `F` or `NIL`, else `F`. In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
+| APPEND | Lisp lambda function | ? | | see manual pages 11, 61 |
+| APPLY | Host lambda function | ? | | Apply this `function` to these `arguments` in this `environment` and return the result. For bootstrapping, at least, a version of APPLY written in Clojure. All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects. See page 13 of the Lisp 1.5 Programmers Manual. |
+| ASSOC | Lisp lambda function, Host lambda function | ? | ? | If a is an association list such as the one formed by PAIRLIS in the above example, then assoc will produce the first pair whose first term is x. Thus it is a table searching function. All args are assumed to be `beowulf.cons-cell/ConsCell` objects. See page 12 of the Lisp 1.5 Programmers Manual. **NOTE THAT** this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. |
+| ATOM | Host lambda function | ? | PREDICATE | Returns `T` if and only if the argument `x` is bound to an atom; else `F`. It is not clear to me from the documentation whether `(ATOM 7)` should return `T` or `F`. I'm going to assume `T`. |
+| CAR | Host lambda function | ? | | Return the item indicated by the first pointer of a pair. NIL is treated specially: the CAR of NIL is NIL. |
+| CAAAAR | Lisp lambda function | ? | ? | ? |
+| CAAADR | Lisp lambda function | ? | ? | ? |
+| CAAAR | Lisp lambda function | ? | ? | ? |
+| CAADAR | Lisp lambda function | ? | ? | ? |
+| CAADDR | Lisp lambda function | ? | ? | ? |
+| CAADR | Lisp lambda function | ? | ? | ? |
+| CAAR | Lisp lambda function | ? | ? | ? |
+| CADAAR | Lisp lambda function | ? | ? | ? |
+| CADADR | Lisp lambda function | ? | ? | ? |
+| CADAR | Lisp lambda function | ? | ? | ? |
+| CADDAR | Lisp lambda function | ? | ? | ? |
+| CADDDR | Lisp lambda function | ? | ? | ? |
+| CADDR | Lisp lambda function | ? | ? | ? |
+| CADR | Lisp lambda function | ? | ? | ? |
+| CDAAAR | Lisp lambda function | ? | ? | ? |
+| CDAADR | Lisp lambda function | ? | ? | ? |
+| CDAAR | Lisp lambda function | ? | ? | ? |
+| CDADAR | Lisp lambda function | ? | ? | ? |
+| CDADDR | Lisp lambda function | ? | ? | ? |
+| CDADR | Lisp lambda function | ? | ? | ? |
+| CDAR | Lisp lambda function | ? | ? | ? |
+| CDDAAR | Lisp lambda function | ? | ? | ? |
+| CDDADR | Lisp lambda function | ? | ? | ? |
+| CDDAR | Lisp lambda function | ? | ? | ? |
+| CDDDAR | Lisp lambda function | ? | ? | ? |
+| CDDDDR | Lisp lambda function | ? | ? | ? |
+| CDDDR | Lisp lambda function | ? | ? | ? |
+| CDDR | Lisp lambda function | ? | ? | ? |
+| CDR | Host lambda function | ? | | Return the item indicated by the second pointer of a pair. NIL is treated specially: the CDR of NIL is NIL. |
+| CONS | Host lambda function | ? | | Construct a new instance of cons cell with this `car` and `cdr`. |
+| CONSP | Host lambda function | ? | ? | Return `T` if object `o` is a cons cell, else `F`. **NOTE THAT** this is an extension function, not available in strct mode. I believe that Lisp 1.5 did not have any mechanism for testing whether an argument was, or was not, a cons cell. |
+| COPY | Lisp lambda function | ? | | see manual pages 62 |
+| DEFINE | Host lambda function | ? | PSEUDO-FUNCTION | Bootstrap-only version of `DEFINE` which, post boostrap, can be overwritten in LISP. The single argument to `DEFINE` should be an association list of symbols to lambda functions. See page 58 of the manual. |
+| DIFFERENCE | Host lambda function | ? | | ? |
+| DIVIDE | Lisp lambda function | ? | | see manual pages 26, 64 |
+| DOC | Host lambda function | ? | ? | Open the page for this `symbol` in the Lisp 1.5 manual, if known, in the default web browser. **NOTE THAT** this is an extension function, not available in strct mode. |
+| EFFACE | Lisp lambda function | ? | PSEUDO-FUNCTION | see manual pages 63 |
| ERROR | Host lambda function | ? | PSEUDO-FUNCTION | Throw an error |
| EQ | Host lambda function | ? | PREDICATE | Returns `T` if and only if both `x` and `y` are bound to the same atom, else `NIL`. |
| EQUAL | Host lambda function | ? | PREDICATE | This is a predicate that is true if its two arguments are identical S-expressions, and false if they are different. (The elementary predicate `EQ` is defined only for atomic arguments.) The definition of `EQUAL` is an example of a conditional expression inside a conditional expression. NOTE: returns `F` on failure, not `NIL` |
@@ -161,50 +164,50 @@ now be possible to reimplement them as `FEXPRs` and so the reader macro function
| FACTORIAL | Lisp lambda function | ? | ? | ? |
| FIXP | Host lambda function | ? | PREDICATE | ? |
| GENSYM | Host lambda function | ? | | Generate a unique symbol. |
-| GET | Host lambda function | ? | | From the manual: '`get` is somewhat like `prop`; however its value is car of the rest of the list if the `indicator` is found, and NIL otherwise.'
It's clear that `GET` is expected to be defined in terms of `PROP`, but we can't implement `PROP` here because we lack `EVAL`; and we can't have `EVAL` here because both it and `APPLY` depends on `GET`.
OK, It's worse than that: the statement of the definition of `GET` (and of) `PROP` on page 59 says that the first argument to each must be a list; But the in the definition of `ASSOC` on page 70, when `GET` is called its first argument is always an atom. Since it's `ASSOC` and `EVAL` which I need to make work, I'm going to assume that page 59 is wrong. |
+| GET | Host lambda function | ? | | From the manual: '`get` is somewhat like `prop`; however its value is car of the rest of the list if the `indicator` is found, and NIL otherwise.' It's clear that `GET` is expected to be defined in terms of `PROP`, but we can't implement `PROP` here because we lack `EVAL`; and we can't have `EVAL` here because both it and `APPLY` depends on `GET`. OK, It's worse than that: the statement of the definition of `GET` (and of) `PROP` on page 59 says that the first argument to each must be a list; But the in the definition of `ASSOC` on page 70, when `GET` is called its first argument is always an atom. Since it's `ASSOC` and `EVAL` which I need to make work, I'm going to assume that page 59 is wrong. |
| GREATERP | Host lambda function | ? | PREDICATE | ? |
| INTEROP | Host lambda function | ? | ? | ? |
| INTERSECTION | Lisp lambda function | ? | ? | ? |
-| LENGTH | Lisp lambda function | ? | | see manual pages 62 |
+| LENGTH | Lisp lambda function | ? | | see manual pages 62 |
| LESSP | Host lambda function | ? | PREDICATE | ? |
-| MAPLIST | Lisp lambda function | ? | FUNCTIONAL | see manual pages 20, 21, 63 |
-| MEMBER | Lisp lambda function | ? | PREDICATE | see manual pages 11, 62 |
-| MINUSP | Lisp lambda function | ? | PREDICATE | see manual pages 26, 64 |
-| NOT | Lisp lambda function | ? | PREDICATE | see manual pages 21, 23, 58 |
-| NULL | Lisp lambda function | ? | PREDICATE | see manual pages 11, 57 |
+| MAPLIST | Lisp lambda function | ? | FUNCTIONAL | see manual pages 20, 21, 63 |
+| MEMBER | Lisp lambda function | ? | PREDICATE | see manual pages 11, 62 |
+| MINUSP | Lisp lambda function | ? | PREDICATE | see manual pages 26, 64 |
+| NOT | Lisp lambda function | ? | PREDICATE | see manual pages 21, 23, 58 |
+| NULL | Lisp lambda function | ? | PREDICATE | see manual pages 11, 57 |
| NUMBERP | Host lambda function | ? | PREDICATE | ? |
-| OBLIST | Host lambda function | ? | | Return a list of the symbols currently bound on the object list.
**NOTE THAT** in the Lisp 1.5 manual, footnote at the bottom of page 69, it implies that an argument can be passed but I'm not sure of the semantics of this. |
-| ONEP | Lisp lambda function | ? | PREDICATE | see manual pages 26, 64 |
-| OR | Host lambda function | ? | PREDICATE | `T` if and only if at least one of my `args` evaluates to something other than either `F` or `NIL`, else `F`.
In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
-| PAIR | Lisp lambda function | ? | | see manual pages 60 |
-| PAIRLIS | Lisp lambda function, Host lambda function | ? | ? | This function gives the list of pairs of corresponding elements of the lists `x` and `y`, and APPENDs this to the list `a`. The resultant list of pairs, which is like a table with two columns, is called an association list. Essentially, it builds the environment on the stack, implementing shallow binding.
All args are assumed to be `beowulf.cons-cell/ConsCell` objects. See page 12 of the Lisp 1.5 Programmers Manual.
**NOTE THAT** this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. |
+| OBLIST | Host lambda function | ? | | Return a list of the symbols currently bound on the object list. **NOTE THAT** in the Lisp 1.5 manual, footnote at the bottom of page 69, it implies that an argument can be passed but I'm not sure of the semantics of this. |
+| ONEP | Lisp lambda function | ? | PREDICATE | see manual pages 26, 64 |
+| OR | Host lambda function | ? | PREDICATE | `T` if and only if at least one of my `args` evaluates to something other than either `F` or `NIL`, else `F`. In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
+| PAIR | Lisp lambda function | ? | | see manual pages 60 |
+| PAIRLIS | Lisp lambda function, Host lambda function | ? | ? | This function gives the list of pairs of corresponding elements of the lists `x` and `y`, and APPENDs this to the list `a`. The resultant list of pairs, which is like a table with two columns, is called an association list. Eessentially, it builds the environment on the stack, implementing shallow binding. All args are assumed to be `beowulf.cons-cell/ConsCell` objects. See page 12 of the Lisp 1.5 Programmers Manual. **NOTE THAT** this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. |
| PLUS | Host lambda function | ? | | ? |
| PRETTY | | ? | ? | ? |
-| PRINT | | ? | PSEUDO-FUNCTION | see manual pages 65, 84 |
-| PROG | Host nlambda function | ? | | The accursed `PROG` feature. See page 71 of the manual.
Lisp 1.5 introduced `PROG`, and most Lisps have been stuck with it ever since. It introduces imperative programming into what should be a pure functional language, and consequently it's going to be a pig to implement. Broadly, `PROG` is a variadic pseudo function called as a `FEXPR` (or possibly an `FSUBR`, although I'm not presently sure that would even work.) The arguments, which are unevaluated, are a list of forms, the first of which is expected to be a list of symbols which will be treated as names of variables within the program, and the rest of which (the 'program body') are either lists or symbols. Lists are treated as Lisp expressions which may be evaulated in turn. Symbols are treated as targets for the `GO` statement.
- **GO:** A `GO` statement takes the form of `(GO target)`, where `target` should be one of the symbols which occur at top level among that particular invocation of `PROG`s arguments. A `GO` statement may occur at top level in a PROG, or in a clause of a `COND` statement in a `PROG`, but not in a function called from the `PROG` statement. When a `GO` statement is evaluated, execution should transfer immediately to the expression which is the argument list immediately following the symbol which is its target. If the target is not found, an error with the code `A6` should be thrown.
- **RETURN:** A `RETURN` statement takes the form `(RETURN value)`, where `value` is any value. Following the evaluation of a `RETURN` statement, the `PROG` should immediately exit without executing any further expressions, returning the value.
- **SET and SETQ:** In addition to the above, if a `SET` or `SETQ` expression is encountered in any expression within the `PROG` body, it should affect not the global object list but instead only the local variables of the program.
- **COND:** In **strict** mode, when in normal execution, a `COND` statement none of whose clauses match should not return `NIL` but should throw an error with the code `A3`... *except* that inside a `PROG` body, it should not do so. *sigh*.
**Flow of control:** Apart from the exceptions specified above, expressions in the program body are evaluated sequentially. If execution reaches the end of the program body, `NIL` is returned.
Got all that? Good. |
-| PROP | Lisp lambda function | ? | FUNCTIONAL | see manual pages 59 |
-| QUOTE | Lisp lambda function | ? | | see manual pages 10, 22, 71 |
-| QUOTIENT | Host lambda function | ? | | I'm not certain from the documentation whether Lisp 1.5 `QUOTIENT` returned the integer part of the quotient, or a realnum representing the whole quotient. I am for now implementing the latter. |
+| PRINT | | ? | PSEUDO-FUNCTION | see manual pages 65, 84 |
+| PROG | Host nlambda function | ? | | The accursed `PROG` feature. See page 71 of the manual. Lisp 1.5 introduced `PROG`, and most Lisps have been stuck with it ever since. It introduces imperative programming into what should be a pure functional language, and consequently it's going to be a pig to implement. Broadly, `PROG` is a variadic pseudo function called as a `FEXPR` (or possibly an `FSUBR`, although I'm not presently sure that would even work.) The arguments, which are unevaluated, are a list of forms, the first of which is expected to be a list of symbols which will be treated as names of variables within the program, and the rest of which (the 'program body') are either lists or symbols. Lists are treated as Lisp expressions which may be evaulated in turn. Symbols are treated as targets for the `GO` statement. **GO:** A `GO` statement takes the form of `(GO target)`, where `target` should be one of the symbols which occur at top level among that particular invocation of `PROG`s arguments. A `GO` statement may occur at top level in a PROG, or in a clause of a `COND` statement in a `PROG`, but not in a function called from the `PROG` statement. When a `GO` statement is evaluated, execution should transfer immediately to the expression which is the argument list immediately following the symbol which is its target. If the target is not found, an error with the code `A6` should be thrown. **RETURN:** A `RETURN` statement takes the form `(RETURN value)`, where `value` is any value. Following the evaluation of a `RETURN` statement, the `PROG` should immediately exit without executing any further expressions, returning the value. **SET and SETQ:** In addition to the above, if a `SET` or `SETQ` expression is encountered in any expression within the `PROG` body, it should affect not the global object list but instead only the local variables of the program. **COND:** In **strict** mode, when in normal execution, a `COND` statement none of whose clauses match should not return `NIL` but should throw an error with the code `A3`... *except* that inside a `PROG` body, it should not do so. *sigh*. **Flow of control:** Apart from the exceptions specified above, expressions in the program body are evaluated sequentially. If execution reaches the end of the program body, `NIL` is returned. Got all that? Good. |
+| PROP | Lisp lambda function | ? | FUNCTIONAL | see manual pages 59 |
+| QUOTE | Lisp lambda function | ? | | see manual pages 10, 22, 71 |
+| QUOTIENT | Host lambda function | ? | | I'm not certain from the documentation whether Lisp 1.5 `QUOTIENT` returned the integer part of the quotient, or a realnum representing the whole quotient. I am for now implementing the latter. |
| RANGE | Lisp lambda function | ? | ? | ? |
| READ | Host lambda function | ? | PSEUDO-FUNCTION | An implementation of a Lisp reader sufficient for bootstrapping; not necessarily the final Lisp reader. `input` should be either a string representation of a LISP expression, or else an input stream. A single form will be read. |
| REMAINDER | Host lambda function | ? | | ? |
| REPEAT | Lisp lambda function | ? | ? | ? |
-| RPLACA | Host lambda function | ? | PSEUDO-FUNCTION | Replace the `CAR` pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
-| RPLACD | Host lambda function | ? | PSEUDO-FUNCTION | Replace the `CDR` pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
-| SEARCH | Lisp lambda function | ? | FUNCTIONAL | see manual pages 63 |
-| SET | Host lambda function | ? | PSEUDO-FUNCTION | Implementation of SET in Clojure. Add to the `oblist` a binding of the value of `var` to the value of `val`.
**NOTE WELL**: this is not SETQ! |
+| RPLACA | Host lambda function | ? | PSEUDO-FUNCTION | Replace the CAR pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
+| RPLACD | Host lambda function | ? | PSEUDO-FUNCTION | Replace the CDR pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
+| SEARCH | Lisp lambda function | ? | FUNCTIONAL | see manual pages 63 |
+| SET | Host lambda function | ? | PSEUDO-FUNCTION | Implementation of SET in Clojure. Add to the `oblist` a binding of the value of `var` to the value of `val`. NOTE WELL: this is not SETQ! |
| SUB1 | Lisp lambda function, Host lambda function | ? | | ? |
| SUB2 | Lisp lambda function | ? | ? | ? |
-| SUBLIS | Lisp lambda function | ? | | see manual pages 12, 61 |
-| SUBST | Lisp lambda function | ? | | see manual pages 11, 61 |
-| SYSIN | Host lambda function | ? | ? | Read the contents of the file at this `filename` into the object list. If the file is not a valid Beowulf sysout file, this will probably corrupt the system, you have been warned. File paths will be considered relative to the filepath set when starting Lisp. It is intended that sysout files can be read both from resources within the jar file, and from the file system. If a named file exists in both the file system and the resources, the file system will be preferred.
**NOTE THAT** if the provided `filename` does not end with `.lsp` (which, if you're writing it from the Lisp REPL, it won't), the extension `.lsp` will be appended.
**NOTE THAT** this is an extension function, not available in strct mode. |
-| SYSOUT | Host lambda function | ? | ? | Dump the current content of the object list to file. If no `filepath` is specified, a file name will be constructed of the symbol `Sysout` and the current date. File paths will be considered relative to the filepath set when starting Lisp.
**NOTE THAT** this is an extension function, not available in strict mode. |
-| TERPRI | | ? | PSEUDO-FUNCTION | see manual pages 65, 84 |
+| SUBLIS | Lisp lambda function | ? | | see manual pages 12, 61 |
+| SUBST | Lisp lambda function | ? | | see manual pages 11, 61 |
+| SYSIN | Host lambda function | ? | ? | Read the contents of the file at this `filename` into the object list. If the file is not a valid Beowulf sysout file, this will probably corrupt the system, you have been warned. File paths will be considered relative to the filepath set when starting Lisp. It is intended that sysout files can be read both from resources within the jar file, and from the file system. If a named file exists in both the file system and the resources, the file system will be preferred. **NOTE THAT** if the provided `filename` does not end with `.lsp` (which, if you're writing it from the Lisp REPL, it won't), the extension `.lsp` will be appended. **NOTE THAT** this is an extension function, not available in strct mode. |
+| SYSOUT | Host lambda function | ? | ? | Dump the current content of the object list to file. If no `filepath` is specified, a file name will be constructed of the symbol `Sysout` and the current date. File paths will be considered relative to the filepath set when starting Lisp. **NOTE THAT** this is an extension function, not available in strct mode. |
+| TERPRI | | ? | PSEUDO-FUNCTION | see manual pages 65, 84 |
| TIMES | Host lambda function | ? | | ? |
| TRACE | Host lambda function | ? | PSEUDO-FUNCTION | Add this `s` to the set of symbols currently being traced. If `s` is not a symbol or sequence of symbols, does nothing. |
| UNION | Lisp lambda function | ? | ? | ? |
-| UNTRACE | Host lambda function | ? | PSEUDO-FUNCTION | Remove this `s` from the set of symbols currently being traced. If `s` is not a symbol or sequence of symbols, does nothing. |
-| ZEROP | Lisp lambda function | ? | PREDICATE | see manual pages 26, 64 |
+| UNTRACE | Host lambda function | ? | PSEUDO-FUNCTION | Remove this `s` from the set of symbols currently being traced. If `s` is not a symbol or sequence of symbols, does nothing. |
+| ZEROP | Lisp lambda function | ? | PREDICATE | see manual pages 26, 64 |
Functions described as 'Lisp function' above are defined in the default
sysout file, `resources/lisp1.5.lsp`, which will be loaded by default unless
@@ -216,7 +219,8 @@ over the Clojure implementations.
### Architectural plan
-Not everything documented in this section is yet built. It indicates the direction of travel and intended destination, not the current state.
+Not everything documented in this section is yet built. It indicates the
+direction of travel and intended destination, not the current state.
#### resources/lisp1.5.lsp
diff --git a/doc/lisp1.5.md b/doc/lisp1.5.md
index 6042cc8..11fe6db 100644
--- a/doc/lisp1.5.md
+++ b/doc/lisp1.5.md
@@ -1721,6 +1721,7 @@ represented in storage only once,
The following simple example has been included to illustrate the exact construction
of list structures. Two types of list structures are shown, and a function for deriving
one from the other is given in LISP.
+
We assume that we have a list of the form
n, = ((A B C) (D E F),... , (X Y z)),
@@ -2709,7 +2710,9 @@ If `deflist` or `define` is used twice on the same object with the same indicato
The function attrib concatenates its two arguments by changing the last element of its first argument to point to the second argument. Thus it is commonly used to tack something onto the end of a property list. The value of attrib is the second argument.
For example
-attrib[~~; (EXPR (LAMBDA (X) (COND ((ATOM X) X) (T (FF (CAR x))))))]
+```
+attrib[FF; (EXPR (LAMBDA (X) (COND ((ATOM X) X) (T (FF (CAR x))))))]
+```
would put EXPR followed by the LAMBDA expression for FF onto the end of the prop-
erty list for FF.
diff --git a/docs/cloverage/beowulf/bootstrap.clj.html b/docs/cloverage/beowulf/bootstrap.clj.html
index c45387d..8a1fa87 100644
--- a/docs/cloverage/beowulf/bootstrap.clj.html
+++ b/docs/cloverage/beowulf/bootstrap.clj.html
@@ -331,13 +331,13 @@
109 ;; else
-
+
110 (beowulf.bootstrap/EVAL expr
-
+
111 (merge-vars vars env)
-
+
112 depth))))
@@ -352,13 +352,13 @@
116
-
+
117 Lisp 1.5 introduced `PROG`, and most Lisps have been stuck with it ever
-
+
118 since. It introduces imperative programming into what should be a pure
-
+
119 functional language, and consequently it's going to be a pig to implement.
@@ -757,7 +757,7 @@
251 (let [lisp-fn (value function-symbol '(EXPR FEXPR))
-
+
252 args' (cond (= NIL args) args
diff --git a/docs/cloverage/beowulf/cons_cell.clj.html b/docs/cloverage/beowulf/cons_cell.clj.html
index a229691..aaf1230 100644
--- a/docs/cloverage/beowulf/cons_cell.clj.html
+++ b/docs/cloverage/beowulf/cons_cell.clj.html
@@ -259,7 +259,7 @@
085 (if
-
+
086 (or
@@ -445,22 +445,22 @@
147 clojure.lang.Counted
-
+
148 (count [this] (loop [cell this
149 result 1]
-
+
150 (if
-
+
151 (and (coll? (.getCdr cell)) (not= NIL (.getCdr cell)))
-
+
152 (recur (.getCdr cell) (inc result))
-
+
153 result)))
diff --git a/docs/cloverage/beowulf/core.clj.html b/docs/cloverage/beowulf/core.clj.html
index 209aa59..adf35d5 100644
--- a/docs/cloverage/beowulf/core.clj.html
+++ b/docs/cloverage/beowulf/core.clj.html
@@ -154,10 +154,10 @@
050 :default default-sysout
-
+
051 :validate [#(and
-
+
052 (.exists (io/file %))
@@ -170,40 +170,40 @@
055 ["-s" "--strict" "Strictly interpret the Lisp 1.5 language, without extensions."]
- 056 ["-t" "--time" "Time evaluations."]])
+ 056 ["-t" "--time" "Time evaluations."]
+
+
+ 057 ["-x" "--testing" "Disable the jline reader - useful when piping input."]])
- 057
+ 058
- 058 (defn- re
+ 059 (defn- re
- 059 "Like REPL, but it isn't a loop and doesn't print."
+ 060 "Like REPL, but it isn't a loop and doesn't print."
- 060 [input]
+ 061 [input]
- 061 (EVAL (READ input) NIL 0))
+ 062 (EVAL (READ input) NIL 0))
- 062
+ 063
- 063 (defn repl
+ 064 (defn repl
- 064 "Read/eval/print loop."
+ 065 "Read/eval/print loop."
- 065 [prompt]
+ 066 [prompt]
- 066 (loop []
-
-
- 067 (print prompt)
+ 067 (loop []
068 (flush)
@@ -211,8 +211,8 @@
069 (try
-
- 070 (if-let [input (trim (read-from-console))]
+
+ 070 (if-let [input (trim (read-from-console prompt))]
071 (if (= input stop-word)
@@ -259,7 +259,7 @@
085 data
-
+
086 (case (:cause data)
@@ -316,13 +316,13 @@
104 (str "Síðe " (System/getProperty "beowulf.version") "\n"))
-
+
105 (when
106 (:help (:options args))
-
+
107 (:summary args))
@@ -358,8 +358,8 @@
118 (try
-
- 119 (repl (str (:prompt (:options args)) " "))
+
+ 119 (repl (:prompt (:options args)))
120 (catch
diff --git a/docs/cloverage/beowulf/host.clj.html b/docs/cloverage/beowulf/host.clj.html
index 5a4bbed..e11a000 100644
--- a/docs/cloverage/beowulf/host.clj.html
+++ b/docs/cloverage/beowulf/host.clj.html
@@ -130,19 +130,19 @@
042 [symbol]
-
+
043 (when (:strict *options*)
-
+
044 (throw (ex-info (format "%s ne āfand innan Lisp 1.5" symbol)
-
+
045 {:type :strict
046 :phase :host
-
+
047 :function symbol})))
@@ -274,7 +274,7 @@
090 [l path]
-
+
091 (cond
@@ -283,1439 +283,1493 @@
093 (empty? path) l
-
- 094 :else
+
+ 094 (not (instance? ConsCell l)) (throw (ex-info (str "Ne liste: "
-
- 095 (try
+
+ 095 l "; " (type l))
+
+
+ 096 {:phase :eval
+
+
+ 097 :function "universal access function"
+
+
+ 098 :args [l path]
+
+
+ 099 :type :beowulf}))
- 096 (case (last path)
+ 100 :else (case (last path)
- 097 \a (uaf (.first l) (butlast path))
+ 101 \a (uaf (.first l) (butlast path))
- 098 \d (uaf (.getCdr l) (butlast path))
+ 102 \d (uaf (.getCdr l) (butlast path))
-
- 099 (throw (ex-info (str "uaf: unexpected letter in path (only `a` and `d` permitted): " (last path))
+
+ 103 (throw (ex-info (str "uaf: unexpected letter in path (only `a` and `d` permitted): "
-
- 100 {:cause :uaf
+
+ 104 (last path))
+
+
+ 105 {:phase :eval
- 101 :detail :unexpected-letter
+ 106 :function "universal access function"
-
- 102 :expr (last path)})))
+
+ 107 :args [l path]
- 103 (catch ClassCastException e
-
-
- 104 (throw (ex-info
-
-
- 105 (str "uaf: Not a LISP list? " (type l))
-
-
- 106 {:cause :uaf
-
-
- 107 :detail :not-a-lisp-list
-
-
- 108 :expr l}
-
-
- 109 e))))))
+ 108 :type :beowulf})))))
- 110
+ 109
- 111 (defmacro CAAR [x] `(uaf ~x '(\a \a)))
+ 110 (defmacro CAAR [x] `(uaf ~x '(\a \a)))
- 112 (defmacro CADR [x] `(uaf ~x '(\a \d)))
+ 111 (defmacro CADR [x] `(uaf ~x '(\a \d)))
-
- 113 (defmacro CDDR [x] `(uaf ~x '(\d \d)))
+
+ 112 (defmacro CDDR [x] `(uaf ~x '(\d \d)))
- 114 (defmacro CDAR [x] `(uaf ~x '(\d \a)))
+ 113 (defmacro CDAR [x] `(uaf ~x '(\d \a)))
- 115
+ 114
- 116 (defmacro CAAAR [x] `(uaf ~x '(\a \a \a)))
+ 115 (defmacro CAAAR [x] `(uaf ~x '(\a \a \a)))
- 117 (defmacro CAADR [x] `(uaf ~x '(\a \a \d)))
+ 116 (defmacro CAADR [x] `(uaf ~x '(\a \a \d)))
- 118 (defmacro CADAR [x] `(uaf ~x '(\a \d \a)))
+ 117 (defmacro CADAR [x] `(uaf ~x '(\a \d \a)))
- 119 (defmacro CADDR [x] `(uaf ~x '(\a \d \d)))
+ 118 (defmacro CADDR [x] `(uaf ~x '(\a \d \d)))
- 120 (defmacro CDDAR [x] `(uaf ~x '(\d \d \a)))
+ 119 (defmacro CDDAR [x] `(uaf ~x '(\d \d \a)))
- 121 (defmacro CDDDR [x] `(uaf ~x '(\d \d \d)))
+ 120 (defmacro CDDDR [x] `(uaf ~x '(\d \d \d)))
- 122 (defmacro CDAAR [x] `(uaf ~x '(\d \a \a)))
+ 121 (defmacro CDAAR [x] `(uaf ~x '(\d \a \a)))
- 123 (defmacro CDADR [x] `(uaf ~x '(\d \a \d)))
+ 122 (defmacro CDADR [x] `(uaf ~x '(\d \a \d)))
- 124
+ 123
- 125 (defmacro CAAAAR [x] `(uaf ~x '(\a \a \a \a)))
+ 124 (defmacro CAAAAR [x] `(uaf ~x '(\a \a \a \a)))
- 126 (defmacro CAADAR [x] `(uaf ~x '(\a \a \d \a)))
+ 125 (defmacro CAADAR [x] `(uaf ~x '(\a \a \d \a)))
- 127 (defmacro CADAAR [x] `(uaf ~x '(\a \d \a \a)))
+ 126 (defmacro CADAAR [x] `(uaf ~x '(\a \d \a \a)))
- 128 (defmacro CADDAR [x] `(uaf ~x '(\a \d \d \a)))
+ 127 (defmacro CADDAR [x] `(uaf ~x '(\a \d \d \a)))
- 129 (defmacro CDDAAR [x] `(uaf ~x '(\d \d \a \a)))
+ 128 (defmacro CDDAAR [x] `(uaf ~x '(\d \d \a \a)))
- 130 (defmacro CDDDAR [x] `(uaf ~x '(\d \d \d \a)))
+ 129 (defmacro CDDDAR [x] `(uaf ~x '(\d \d \d \a)))
- 131 (defmacro CDAAAR [x] `(uaf ~x '(\d \a \a \a)))
+ 130 (defmacro CDAAAR [x] `(uaf ~x '(\d \a \a \a)))
- 132 (defmacro CDADAR [x] `(uaf ~x '(\d \a \d \a)))
+ 131 (defmacro CDADAR [x] `(uaf ~x '(\d \a \d \a)))
- 133 (defmacro CAAADR [x] `(uaf ~x '(\a \a \a \d)))
+ 132 (defmacro CAAADR [x] `(uaf ~x '(\a \a \a \d)))
- 134 (defmacro CAADDR [x] `(uaf ~x '(\a \a \d \d)))
+ 133 (defmacro CAADDR [x] `(uaf ~x '(\a \a \d \d)))
- 135 (defmacro CADADR [x] `(uaf ~x '(\a \d \a \d)))
+ 134 (defmacro CADADR [x] `(uaf ~x '(\a \d \a \d)))
- 136 (defmacro CADDDR [x] `(uaf ~x '(\a \d \d \d)))
+ 135 (defmacro CADDDR [x] `(uaf ~x '(\a \d \d \d)))
- 137 (defmacro CDDADR [x] `(uaf ~x '(\d \d \a \d)))
+ 136 (defmacro CDDADR [x] `(uaf ~x '(\d \d \a \d)))
- 138 (defmacro CDDDDR [x] `(uaf ~x '(\d \d \d \d)))
+ 137 (defmacro CDDDDR [x] `(uaf ~x '(\d \d \d \d)))
- 139 (defmacro CDAADR [x] `(uaf ~x '(\d \a \a \d)))
+ 138 (defmacro CDAADR [x] `(uaf ~x '(\d \a \a \d)))
- 140 (defmacro CDADDR [x] `(uaf ~x '(\d \a \d \d)))
+ 139 (defmacro CDADDR [x] `(uaf ~x '(\d \a \d \d)))
- 141
+ 140
- 142 (defn RPLACA
+ 141 (defn RPLACA
- 143 "Replace the CAR pointer of this `cell` with this `value`. Dangerous, should
+ 142 "Replace the CAR pointer of this `cell` with this `value`. Dangerous, should
- 144 really not exist, but does in Lisp 1.5 (and was important for some
+ 143 really not exist, but does in Lisp 1.5 (and was important for some
- 145 performance hacks in early Lisps)"
+ 144 performance hacks in early Lisps)"
- 146 [^ConsCell cell value]
+ 145 [^ConsCell cell value]
- 147 (if
+ 146 (if
- 148 (instance? ConsCell cell)
+ 147 (instance? ConsCell cell)
- 149 (if
+ 148 (if
- 150 (or
+ 149 (or
- 151 (instance? ConsCell value)
+ 150 (instance? ConsCell value)
- 152 (number? value)
+ 151 (number? value)
- 153 (symbol? value)
+ 152 (symbol? value)
- 154 (= value NIL))
+ 153 (= value NIL))
- 155 (try
+ 154 (try
- 156 (.rplaca cell value)
+ 155 (.rplaca cell value)
- 157 cell
+ 156 cell
- 158 (catch Throwable any
+ 157 (catch Throwable any
- 159 (throw (ex-info
+ 158 (throw (ex-info
- 160 (str (.getMessage any) " in RPLACA: `")
+ 159 (str (.getMessage any) " in RPLACA: `")
- 161 {:cause :upstream-error
+ 160 {:cause :upstream-error
- 162 :phase :host
+ 161 :phase :host
- 163 :function :rplaca
+ 162 :function :rplaca
- 164 :args (list cell value)
+ 163 :args (list cell value)
- 165 :type :beowulf}
+ 164 :type :beowulf}
- 166 any))))
+ 165 any))))
- 167 (throw (ex-info
+ 166 (throw (ex-info
- 168 (str "Un-ġefōg þing in RPLACA: `" value "` (" (type value) ")")
+ 167 (str "Un-ġefōg þing in RPLACA: `" value "` (" (type value) ")")
- 169 {:cause :bad-value
+ 168 {:cause :bad-value
- 170 :phase :host
+ 169 :phase :host
- 171 :function :rplaca
+ 170 :function :rplaca
- 172 :args (list cell value)
+ 171 :args (list cell value)
- 173 :type :beowulf})))
+ 172 :type :beowulf})))
- 174 (throw (ex-info
+ 173 (throw (ex-info
- 175 (str "Uncynlic miercels in RPLACA: `" cell "` (" (type cell) ")")
+ 174 (str "Uncynlic miercels in RPLACA: `" cell "` (" (type cell) ")")
- 176 {:cause :bad-cell
+ 175 {:cause :bad-cell
- 177 :phase :host
+ 176 :phase :host
- 178 :function :rplaca
+ 177 :function :rplaca
- 179 :args (list cell value)
+ 178 :args (list cell value)
- 180 :type :beowulf}))))
+ 179 :type :beowulf}))))
- 181
+ 180
- 182 (defn RPLACD
+ 181 (defn RPLACD
- 183 "Replace the CDR pointer of this `cell` with this `value`. Dangerous, should
+ 182 "Replace the CDR pointer of this `cell` with this `value`. Dangerous, should
- 184 really not exist, but does in Lisp 1.5 (and was important for some
+ 183 really not exist, but does in Lisp 1.5 (and was important for some
- 185 performance hacks in early Lisps)"
+ 184 performance hacks in early Lisps)"
- 186 [^ConsCell cell value]
+ 185 [^ConsCell cell value]
- 187 (if
+ 186 (if
- 188 (instance? ConsCell cell)
+ 187 (instance? ConsCell cell)
- 189 (if
+ 188 (if
-
- 190 (or
+
+ 189 (or
- 191 (instance? ConsCell value)
+ 190 (instance? ConsCell value)
- 192 (number? value)
+ 191 (number? value)
- 193 (symbol? value)
-
-
- 194 (= value NIL))
-
-
- 195 (try
+ 192 (symbol? value)
- 196 (.rplacd cell value)
+ 193 (= value NIL))
- 197 cell
+ 194 (try
+
+
+ 195 (.rplacd cell value)
+
+
+ 196 cell
- 198 (catch Throwable any
+ 197 (catch Throwable any
- 199 (throw (ex-info
+ 198 (throw (ex-info
- 200 (str (.getMessage any) " in RPLACD: `")
+ 199 (str (.getMessage any) " in RPLACD: `")
- 201 {:cause :upstream-error
+ 200 {:cause :upstream-error
- 202 :phase :host
+ 201 :phase :host
- 203 :function :rplacd
+ 202 :function :rplacd
- 204 :args (list cell value)
+ 203 :args (list cell value)
- 205 :type :beowulf}
+ 204 :type :beowulf}
- 206 any))))
-
-
- 207 (throw (ex-info
-
-
- 208 (str "Un-ġefōg þing in RPLACD: `" value "` (" (type value) ")")
-
-
- 209 {:cause :bad-value
-
-
- 210 :phase :host
-
-
- 211 :function :rplacd
-
-
- 212 :args (list cell value)
-
-
- 213 :type :beowulf})))
-
-
- 214 (throw (ex-info
-
-
- 215 (str "Uncynlic miercels in RPLACD: `" cell "` (" (type cell) ")")
-
-
- 216 {:cause :bad-cell
-
-
- 217 :phase :host
-
-
- 218 :detail :rplacd
-
-
- 219 :args (list cell value)
-
-
- 220 :type :beowulf}))));; PLUS
-
-
- 221
-
-
- 222 (defn LIST
-
-
- 223 [& args]
+ 205 any))))
- 224 (make-beowulf-list args))
+ 206 (throw (ex-info
+
+
+ 207 (str "Un-ġefōg þing in RPLACD: `" value "` (" (type value) ")")
+
+
+ 208 {:cause :bad-value
+
+
+ 209 :phase :host
+
+
+ 210 :function :rplacd
+
+
+ 211 :args (list cell value)
+
+
+ 212 :type :beowulf})))
+
+
+ 213 (throw (ex-info
+
+
+ 214 (str "Uncynlic miercels in RPLACD: `" cell "` (" (type cell) ")")
+
+
+ 215 {:cause :bad-cell
+
+
+ 216 :phase :host
+
+
+ 217 :detail :rplacd
+
+
+ 218 :args (list cell value)
+
+
+ 219 :type :beowulf}))));; PLUS
- 225
-
-
- 226 ;;;; Basic predicates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- 227
-
-
- 228 (defmacro NULL
-
-
- 229 "Returns `T` if and only if the argument `x` is bound to `NIL`; else `F`."
-
-
- 230 [x]
-
-
- 231 `(if (= ~x NIL) T F))
-
-
- 232
-
-
- 233 (defmacro NILP
-
-
- 234 "Not part of LISP 1.5: `T` if `o` is `NIL`, else `NIL`."
-
-
- 235 [x]
-
-
- 236 `(if (= ~x NIL) T NIL))
-
-
- 237
+ 220
- 238 (defn ATOM
+ 221 (defn LIST
- 239 "Returns `T` if and only if the argument `x` is bound to an atom; else `F`.
+ 222 [& args]
+
+
+ 223 (make-beowulf-list args))
+
+
+ 224
- 240 It is not clear to me from the documentation whether `(ATOM 7)` should return
+ 225 ;;;; Basic predicates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+ 226
+
+
+ 227 (defmacro NULL
- 241 `T` or `F`. I'm going to assume `T`."
+ 228 "Returns `T` if and only if the argument `x` is bound to `NIL`; else `F`."
- 242 [x]
+ 229 [x]
+
+
+ 230 `(if (= ~x NIL) T F))
+
+
+ 231
+
+
+ 232 (defmacro NILP
+
+
+ 233 "Not part of LISP 1.5: `T` if `o` is `NIL`, else `NIL`."
+
+
+ 234 [x]
+
+
+ 235 `(if (= ~x NIL) T NIL))
+
+
+ 236
+
+
+ 237 (defn ATOM
+
+
+ 238 "Returns `T` if and only if the argument `x` is bound to an atom; else `F`.
+
+
+ 239 It is not clear to me from the documentation whether `(ATOM 7)` should return
+
+
+ 240 `T` or `F`. I'm going to assume `T`."
+
+
+ 241 [x]
- 243 (if (or (symbol? x) (number? x)) T F))
+ 242 (if (or (symbol? x) (number? x)) T F))
- 244
+ 243
- 245 (defmacro ATOM?
+ 244 (defmacro ATOM?
- 246 "The convention of returning `F` from predicates, rather than `NIL`, is going
+ 245 "The convention of returning `F` from predicates, rather than `NIL`, is going
- 247 to tie me in knots. This is a variant of `ATOM` which returns `NIL`
+ 246 to tie me in knots. This is a variant of `ATOM` which returns `NIL`
- 248 on failure."
+ 247 on failure."
- 249 [x]
+ 248 [x]
- 250 `(if (or (symbol? ~x) (number? ~x)) T NIL))
+ 249 `(if (or (symbol? ~x) (number? ~x)) T NIL))
- 251
+ 250
- 252 (defn EQ
+ 251 (defn EQ
- 253 "Returns `T` if and only if both `x` and `y` are bound to the same atom,
+ 252 "Returns `T` if and only if both `x` and `y` are bound to the same atom,
- 254 else `NIL`."
+ 253 else `NIL`."
- 255 [x y]
+ 254 [x y]
- 256 (cond (and (instance? ConsCell x)
+ 255 (cond (and (instance? ConsCell x)
- 257 (.equals x y)) T
+ 256 (.equals x y)) T
- 258 (and (= (ATOM x) T) (= x y)) T
+ 257 (and (= (ATOM x) T) (= x y)) T
- 259 :else NIL))
+ 258 :else NIL))
- 260
+ 259
- 261 (defn EQUAL
+ 260 (defn EQUAL
- 262 "This is a predicate that is true if its two arguments are identical
+ 261 "This is a predicate that is true if its two arguments are identical
- 263 S-expressions, and false if they are different. (The elementary predicate
+ 262 S-expressions, and false if they are different. (The elementary predicate
- 264 `EQ` is defined only for atomic arguments.) The definition of `EQUAL` is
+ 263 `EQ` is defined only for atomic arguments.) The definition of `EQUAL` is
- 265 an example of a conditional expression inside a conditional expression.
+ 264 an example of a conditional expression inside a conditional expression.
- 266
+ 265
- 267 NOTE: returns `F` on failure, not `NIL`"
+ 266 NOTE: returns `F` on failure, not `NIL`"
- 268 [x y]
+ 267 [x y]
- 269 (cond
+ 268 (cond
- 270 (= (ATOM x) T) (if (= x y) T F)
+ 269 (= (ATOM x) T) (if (= x y) T F)
- 271 (= (EQUAL (CAR x) (CAR y)) T) (EQUAL (CDR x) (CDR y))
+ 270 (= (EQUAL (CAR x) (CAR y)) T) (EQUAL (CDR x) (CDR y))
- 272 :else F))
+ 271 :else F))
- 273
+ 272
- 274 (defn AND
+ 273 (defn AND
- 275 "`T` if and only if none of my `args` evaluate to either `F` or `NIL`,
+ 274 "`T` if and only if none of my `args` evaluate to either `F` or `NIL`,
- 276 else `F`.
+ 275 else `F`.
- 277
+ 276
- 278 In `beowulf.host` principally because I don't yet feel confident to define
+ 277 In `beowulf.host` principally because I don't yet feel confident to define
- 279 varargs functions in Lisp."
+ 278 varargs functions in Lisp."
- 280 [& args]
+ 279 [& args]
- 281 ;; (println "AND: " args " type: " (type args) " seq? " (seq? args))
+ 280 ;; (println "AND: " args " type: " (type args) " seq? " (seq? args))
- 282 ;; (println " filtered: " (seq (filter #{F NIL} args)))
+ 281 ;; (println " filtered: " (seq (filter #{F NIL} args)))
-
- 283 (cond (= NIL args) T
+
+ 282 (cond (= NIL args) T
- 284 (seq? args) (if (seq (filter #{F NIL} args)) F T)
+ 283 (seq? args) (if (seq (filter #{F NIL} args)) F T)
-
- 285 :else T))
+
+ 284 :else T))
+
+
+ 285
286
-
- 287
+
+ 287 (defn OR
+
+
+ 288 "`T` if and only if at least one of my `args` evaluates to something other
+
+
+ 289 than either `F` or `NIL`, else `F`.
+
+
+ 290
+
+
+ 291 In `beowulf.host` principally because I don't yet feel confident to define
+
+
+ 292 varargs functions in Lisp."
+
+
+ 293 [& args]
+
+
+ 294 ;; (println "OR: " args " type: " (type args) " seq? " (seq? args))
+
+
+ 295 ;; (println " filtered: " (seq (remove #{F NIL} args)))
+
+
+ 296 (cond (= NIL args) F
+
+
+ 297 (seq? args) (if (seq (remove #{F NIL} args)) T F)
- 288 (defn OR
+ 298 :else F))
-
- 289 "`T` if and only if at least one of my `args` evaluates to something other
-
-
- 290 than either `F` or `NIL`, else `F`.
-
-
- 291
-
-
- 292 In `beowulf.host` principally because I don't yet feel confident to define
-
-
- 293 varargs functions in Lisp."
-
-
- 294 [& args]
-
-
- 295 ;; (println "OR: " args " type: " (type args) " seq? " (seq? args))
-
-
- 296 ;; (println " filtered: " (seq (remove #{F NIL} args)))
-
-
- 297 (cond (= NIL args) F
-
-
- 298 (seq? args) (if (seq (remove #{F NIL} args)) T F)
-
-
- 299 :else F))
+
+ 299
300
-
- 301
+
+ 301 ;;;; Operations on lists ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- 302 ;;;; Operations on lists ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ 302 ;;
- 303 ;;
-
-
- 304 ;; TODO: These are candidates for moving to Lisp urgently!
+ 303 ;; TODO: These are candidates for moving to Lisp urgently!
- 305
+ 304
- 306 (defn ASSOC
+ 305 (defn ASSOC
- 307 "If a is an association list such as the one formed by PAIRLIS in the above
+ 306 "If a is an association list such as the one formed by PAIRLIS in the above
- 308 example, then assoc will produce the first pair whose first term is x. Thus
+ 307 example, then assoc will produce the first pair whose first term is x. Thus
- 309 it is a table searching function.
+ 308 it is a table searching function.
- 310
+ 309
- 311 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
+ 310 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
- 312 See page 12 of the Lisp 1.5 Programmers Manual.
+ 311 See page 12 of the Lisp 1.5 Programmers Manual.
- 313
+ 312
- 314 **NOTE THAT** this function is overridden by an implementation in Lisp,
+ 313 **NOTE THAT** this function is overridden by an implementation in Lisp,
- 315 but is currently still present for bootstrapping."
+ 314 but is currently still present for bootstrapping."
- 316 [x a]
+ 315 [x a]
- 317 (cond
+ 316 (cond
- 318 (= NIL a) NIL ;; this clause is not present in the original but is added for
+ 317 (= NIL a) NIL ;; this clause is not present in the original but is added for
- 319 ;; robustness.
+ 318 ;; robustness.
- 320 (= (EQUAL (CAAR a) x) T) (CAR a)
+ 319 (= (EQUAL (CAAR a) x) T) (CAR a)
- 321 :else
+ 320 :else
- 322 (ASSOC x (CDR a))))
+ 321 (ASSOC x (CDR a))))
- 323
+ 322
- 324 (defn PAIRLIS
+ 323 (defn PAIRLIS
- 325 "This function gives the list of pairs of corresponding elements of the
+ 324 "This function gives the list of pairs of corresponding elements of the
- 326 lists `x` and `y`, and APPENDs this to the list `a`. The resultant list
+ 325 lists `x` and `y`, and APPENDs this to the list `a`. The resultant list
- 327 of pairs, which is like a table with two columns, is called an
+ 326 of pairs, which is like a table with two columns, is called an
- 328 association list.
+ 327 association list.
- 329
+ 328
- 330 Eessentially, it builds the environment on the stack, implementing shallow
+ 329 Eessentially, it builds the environment on the stack, implementing shallow
- 331 binding.
+ 330 binding.
- 332
+ 331
- 333 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
+ 332 All args are assumed to be `beowulf.cons-cell/ConsCell` objects.
- 334 See page 12 of the Lisp 1.5 Programmers Manual.
+ 333 See page 12 of the Lisp 1.5 Programmers Manual.
- 335
+ 334
- 336 **NOTE THAT** this function is overridden by an implementation in Lisp,
+ 335 **NOTE THAT** this function is overridden by an implementation in Lisp,
- 337 but is currently still present for bootstrapping."
+ 336 but is currently still present for bootstrapping."
- 338 [x y a]
+ 337 [x y a]
- 339 (cond
+ 338 (cond
- 340 ;; the original tests only x; testing y as well will be a little more
+ 339 ;; the original tests only x; testing y as well will be a little more
- 341 ;; robust if `x` and `y` are not the same length.
+ 340 ;; robust if `x` and `y` are not the same length.
- 342 (or (= NIL x) (= NIL y)) a
+ 341 (or (= NIL x) (= NIL y)) a
- 343 :else (make-cons-cell
+ 342 :else (make-cons-cell
- 344 (make-cons-cell (CAR x) (CAR y))
+ 343 (make-cons-cell (CAR x) (CAR y))
- 345 (PAIRLIS (CDR x) (CDR y) a))))
+ 344 (PAIRLIS (CDR x) (CDR y) a))))
- 346
+ 345
- 347 ;;;; Arithmetic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ 346 ;;;; Arithmetic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- 348 ;;
+ 347 ;;
- 349 ;; TODO: When in strict mode, should we limit arithmetic precision to that
+ 348 ;; TODO: When in strict mode, should we limit arithmetic precision to that
- 350 ;; supported by Lisp 1.5?
+ 349 ;; supported by Lisp 1.5?
- 351
+ 350
- 352 (defn PLUS
+ 351 (defn PLUS
- 353 [& args]
+ 352 [& args]
- 354 (let [s (apply + args)]
+ 353 (let [s (apply + args)]
- 355 (if (integer? s) s (float s))))
+ 354 (if (integer? s) s (float s))))
- 356
+ 355
- 357 (defn TIMES
+ 356 (defn TIMES
- 358 [& args]
+ 357 [& args]
- 359 (let [p (apply * args)]
-
-
- 360 (if (integer? p) p (float p))))
-
-
- 361
-
-
- 362 (defn DIFFERENCE
-
-
- 363 [x y]
-
-
- 364 (let [d (- x y)]
-
-
- 365 (if (integer? d) d (float d))))
-
-
- 366
-
-
- 367 (defn QUOTIENT
-
-
- 368 "I'm not certain from the documentation whether Lisp 1.5 `QUOTIENT` returned
-
-
- 369 the integer part of the quotient, or a realnum representing the whole
-
-
- 370 quotient. I am for now implementing the latter."
-
-
- 371 [x y]
-
-
- 372 (let [q (/ x y)]
+ 358 (let [p (apply * args)]
- 373 (if (integer? q) q (float q))))
+ 359 (if (integer? p) p (float p))))
- 374
+ 360
- 375 (defn REMAINDER
+ 361 (defn DIFFERENCE
- 376 [x y]
+ 362 [x y]
+
+
+ 363 (let [d (- x y)]
+
+
+ 364 (if (integer? d) d (float d))))
+
+
+ 365
+
+
+ 366 (defn QUOTIENT
+
+
+ 367 "I'm not certain from the documentation whether Lisp 1.5 `QUOTIENT` returned
+
+
+ 368 the integer part of the quotient, or a realnum representing the whole
+
+
+ 369 quotient. I am for now implementing the latter."
+
+
+ 370 [x y]
+
+
+ 371 (let [q (/ x y)]
+
+
+ 372 (if (integer? q) q (float q))))
+
+
+ 373
+
+
+ 374 (defn REMAINDER
+
+
+ 375 [x y]
- 377 (rem x y))
+ 376 (rem x y))
- 378
+ 377
- 379 (defn ADD1
+ 378 (defn ADD1
- 380 [x]
+ 379 [x]
- 381 (inc x))
+ 380 (inc x))
- 382
+ 381
- 383 (defn SUB1
+ 382 (defn SUB1
- 384 [x]
+ 383 [x]
-
- 385 (dec x))
+
+ 384 (dec x))
- 386
+ 385
- 387 (defn FIXP
+ 386 (defn FIXP
- 388 [x]
-
-
- 389 (if (integer? x) T F))
-
-
- 390
-
-
- 391 (defn NUMBERP
-
-
- 392 [x]
+ 387 [x]
- 393 (if (number? x) T F))
+ 388 (if (integer? x) T F))
- 394
+ 389
- 395 (defn LESSP
+ 390 (defn NUMBERP
- 396 [x y]
+ 391 [x]
-
- 397 (if (< x y) T F))
+
+ 392 (if (number? x) T F))
- 398
+ 393
- 399 (defn GREATERP
+ 394 (defn LESSP
- 400 [x y]
+ 395 [x y]
-
- 401 (if (> x y) T F))
+
+ 396 (if (< x y) T F))
- 402
-
-
- 403 ;;;; Miscellaneous ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- 404
+ 397
- 405 (defn GENSYM
+ 398 (defn GREATERP
- 406 "Generate a unique symbol."
+ 399 [x y]
-
- 407 []
-
-
- 408 (symbol (upper-case (str (gensym "SYM")))))
+
+ 400 (if (> x y) T F))
- 409
+ 401
+
+
+ 402 ;;;; Miscellaneous ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+ 403
- 410 (defn ERROR
+ 404 (defn GENSYM
- 411 "Throw an error"
+ 405 "Generate a unique symbol."
- 412 [& args]
+ 406 []
-
- 413 (throw (ex-info "LISP STÆFLEAHTER" {:args args
-
-
- 414 :phase :eval
-
-
- 415 :function 'ERROR
-
-
- 416 :type :lisp
-
-
- 417 :code (or (first args) 'A1)})))
+
+ 407 (symbol (upper-case (str (gensym "SYM")))))
- 418
-
-
- 419 ;;;; Assignment and the object list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- 420
+ 408
- 421 (defn OBLIST
+ 409 (defn ERROR
- 422 "Return a list of the symbols currently bound on the object list.
+ 410 "Throw an error"
- 423
+ 411 [& args]
+
+
+ 412 (throw (ex-info "LISP STÆFLEAHTER" {:args args
- 424 **NOTE THAT** in the Lisp 1.5 manual, footnote at the bottom of page 69, it implies
+ 413 :phase :eval
- 425 that an argument can be passed but I'm not sure of the semantics of
+ 414 :function 'ERROR
- 426 this."
+ 415 :type :lisp
+
+
+ 416 :code (or (first args) 'A1)})))
+
+
+ 417
- 427 []
+ 418 ;;;; Assignment and the object list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+ 419
+
+
+ 420 (defn OBLIST
+
+
+ 421 "Return a list of the symbols currently bound on the object list.
+
+
+ 422
+
+
+ 423 **NOTE THAT** in the Lisp 1.5 manual, footnote at the bottom of page 69, it implies
+
+
+ 424 that an argument can be passed but I'm not sure of the semantics of
+
+
+ 425 this."
+
+
+ 426 []
- 428 (if (instance? ConsCell @oblist)
+ 427 (if (instance? ConsCell @oblist)
- 429 (make-beowulf-list (map CAR @oblist))
+ 428 (make-beowulf-list (map CAR @oblist))
- 430 NIL))
+ 429 NIL))
- 431
+ 430
- 432 (def magic-marker
+ 431 (def magic-marker
- 433 "The unexplained magic number which marks the start of a property list."
+ 432 "The unexplained magic number which marks the start of a property list."
- 434 (Integer/parseInt "77777" 8))
+ 433 (Integer/parseInt "77777" 8))
- 435
+ 434
- 436 (defn PUT
+ 435 (defn hit-or-miss-assoc
- 437 "Put this `value` as the value of the property indicated by this `indicator`
+ 436 "Find the position of the binding of this `target` in a Lisp 1.5
- 438 of this `symbol`. Return `value` on success.
+ 437 property list `plist`.
- 439
+ 438
- 440 NOTE THAT there is no `PUT` defined in the manual, but it would have been
+ 439 Lisp 1.5 property lists are not assoc lists, but lists of the form
- 441 easy to have defined it so I don't think this fully counts as an extension."
+ 440 `(name value name value name value...)`. It's therefore necessary to
- 442 [symbol indicator value]
-
-
- 443 (if-let [binding (ASSOC symbol @oblist)]
-
-
- 444 (if-let [prop (ASSOC indicator (CDDR binding))]
-
-
- 445 (RPLACD prop value)
-
-
- 446 (RPLACD binding
-
-
- 447 (make-cons-cell
-
-
- 448 magic-marker
-
-
- 449 (make-cons-cell
-
-
- 450 indicator
-
-
- 451 (make-cons-cell value (CDDR binding))))))
-
-
- 452 (swap!
-
-
- 453 oblist
-
-
- 454 (fn [ob s p v]
-
-
- 455 (make-cons-cell
-
-
- 456 (make-beowulf-list (list s magic-marker p v))
-
-
- 457 ob))
-
-
- 458 symbol indicator value)))
-
-
- 459
-
-
- 460 (defn GET
+ 441 recurse down the list two entries at a time to avoid confusing names
- 461 "From the manual:
+ 442 with values."
- 462
+ 443 [target plist]
-
- 463 '`get` is somewhat like `prop`; however its value is car of the rest of
+
+ 444 (if (and (instance? ConsCell plist) (even? (count plist)))
-
- 464 the list if the `indicator` is found, and NIL otherwise.'
-
-
- 465
-
-
- 466 It's clear that `GET` is expected to be defined in terms of `PROP`, but
-
-
- 467 we can't implement `PROP` here because we lack `EVAL`; and we can't have
-
-
- 468 `EVAL` here because both it and `APPLY` depends on `GET`.
-
-
- 469
-
-
- 470 OK, It's worse than that: the statement of the definition of `GET` (and
-
-
- 471 of) `PROP` on page 59 says that the first argument to each must be a list;
-
-
- 472 But the in the definition of `ASSOC` on page 70, when `GET` is called its
-
-
- 473 first argument is always an atom. Since it's `ASSOC` and `EVAL` which I
-
-
- 474 need to make work, I'm going to assume that page 59 is wrong."
-
-
- 475 [symbol indicator]
-
-
- 476 (let [binding (ASSOC symbol @oblist)
-
-
- 477 val (cond
-
-
- 478 (= binding NIL) NIL
-
-
- 479 (= magic-marker
-
-
- 480 (CADR binding)) (loop [b binding]
-
-
- 481 ;; (println "GET loop, seeking " indicator ":")
-
-
- 482 ;; (pretty-print b)
-
-
- 483 (if (instance? ConsCell b)
+
+ 445 (cond (= plist NIL) NIL
- 484 (if (= (CAR b) indicator)
+ 446 (= (first plist) target) plist
+
+
+ 447 :else (hit-or-miss-assoc target (CDDR plist)))
+
+
+ 448 NIL))
+
+
+ 449
+
+
+ 450 (defn PUT
+
+
+ 451 "Put this `value` as the value of the property indicated by this `indicator`
+
+
+ 452 of this `symbol`. Return `value` on success.
+
+
+ 453
+
+
+ 454 NOTE THAT there is no `PUT` defined in the manual, but it would have been
+
+
+ 455 easy to have defined it so I don't think this fully counts as an extension."
+
+
+ 456 [symbol indicator value]
+
+
+ 457 (let [binding (ASSOC symbol @oblist)]
+
+
+ 458 (if (instance? ConsCell binding)
+
+
+ 459 (let [prop (hit-or-miss-assoc indicator (CDDR binding))]
+
+
+ 460 (if (instance? ConsCell prop)
+
+
+ 461 (RPLACA (CDR prop) value)
- 485 (CADR b) ;; <- this is what we should actually be returning
+ 462 (RPLACD binding
+
+
+ 463 (make-cons-cell
- 486 (recur (CDR b)))
+ 464 magic-marker
+
+
+ 465 (make-cons-cell
- 487 NIL))
+ 466 indicator
+
+
+ 467 (make-cons-cell value (CDDR binding)))))))
+
+
+ 468 (swap!
+
+
+ 469 oblist
+
+
+ 470 (fn [ob s p v]
+
+
+ 471 (make-cons-cell
+
+
+ 472 (make-beowulf-list (list s magic-marker p v))
+
+
+ 473 ob))
+
+
+ 474 symbol indicator value)))
+
+
+ 475 value)
+
+
+ 476
+
+
+ 477 (defn GET
+
+
+ 478 "From the manual:
+
+
+ 479
+
+
+ 480 '`get` is somewhat like `prop`; however its value is car of the rest of
+
+
+ 481 the list if the `indicator` is found, and NIL otherwise.'
+
+
+ 482
+
+
+ 483 It's clear that `GET` is expected to be defined in terms of `PROP`, but
+
+
+ 484 we can't implement `PROP` here because we lack `EVAL`; and we can't have
+
+
+ 485 `EVAL` here because both it and `APPLY` depends on `GET`.
+
+
+ 486
+
+
+ 487 OK, It's worse than that: the statement of the definition of `GET` (and
+
+
+ 488 of) `PROP` on page 59 says that the first argument to each must be a list;
+
+
+ 489 But the in the definition of `ASSOC` on page 70, when `GET` is called its
+
+
+ 490 first argument is always an atom. Since it's `ASSOC` and `EVAL` which I
+
+
+ 491 need to make work, I'm going to assume that page 59 is wrong."
+
+
+ 492 [symbol indicator]
+
+
+ 493 (let [binding (ASSOC symbol @oblist)
+
+
+ 494 val (cond
+
+
+ 495 (= binding NIL) NIL
+
+
+ 496 (= magic-marker
+
+
+ 497 (CADR binding)) (loop [b binding]
+
+
+ 498 ;; (println "GET loop, seeking " indicator ":")
+
+
+ 499 ;; (pretty-print b)
+
+
+ 500 (if (instance? ConsCell b)
+
+
+ 501 (if (= (CAR b) indicator)
+
+
+ 502 (CADR b) ;; <- this is what we should actually be returning
+
+
+ 503 (recur (CDR b)))
+
+
+ 504 NIL))
- 488 :else (throw
+ 505 :else (throw
- 489 (ex-info "Misformatted property list (missing magic marker)"
+ 506 (ex-info "Misformatted property list (missing magic marker)"
- 490 {:phase :host
+ 507 {:phase :host
- 491 :function :get
+ 508 :function :get
- 492 :args (list symbol indicator)
+ 509 :args (list symbol indicator)
- 493 :type :beowulf})))]
+ 510 :type :beowulf})))]
- 494 ;; (println "<< GET returning: " val)
+ 511 ;; (println "<< GET returning: " val)
- 495 val))
+ 512 val))
- 496
+ 513
- 497 (defn DEFLIST
+ 514 (defn DEFLIST
- 498 "For each pair in this association list `a-list`, set the property with this
+ 515 "For each pair in this association list `a-list`, set the property with this
- 499 `indicator` of the symbol which is the first element of the pair to the
+ 516 `indicator` of the symbol which is the first element of the pair to the
- 500 value which is the second element of the pair. See page 58 of the manual."
+ 517 value which is the second element of the pair. See page 58 of the manual."
- 501 [a-list indicator]
+ 518 [a-list indicator]
+
+
+ 519 (doall
- 502 (map
+ 520 (map
-
- 503 #(PUT (CAR %) indicator (CDR %))
+
+ 521 #(when (PUT (CAR %) indicator (CDR %)) (CAR %))
- 504 a-list))
+ 522 a-list)))
- 505
+ 523
- 506 (defn DEFINE
+ 524 (defn DEFINE
- 507 "Bootstrap-only version of `DEFINE` which, post boostrap, can be overwritten
+ 525 "Bootstrap-only version of `DEFINE` which, post boostrap, can be overwritten
- 508 in LISP.
+ 526 in LISP.
- 509
+ 527
- 510 The single argument to `DEFINE` should be an association list of symbols to
+ 528 The single argument to `DEFINE` should be an association list of symbols to
- 511 lambda functions. See page 58 of the manual."
+ 529 lambda functions. See page 58 of the manual."
- 512 [a-list]
+ 530 [a-list]
- 513 (DEFLIST a-list 'EXPR))
-
-
- 514
-
-
- 515 (defn SET
-
-
- 516 "Implementation of SET in Clojure. Add to the `oblist` a binding of the
-
-
- 517 value of `var` to the value of `val`. NOTE WELL: this is not SETQ!"
-
-
- 518 [symbol val]
-
-
- 519 (PUT symbol 'APVAL val))
-
-
- 520
-
-
- 521 ;;;; TRACE and friends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- 522
-
-
- 523 (def traced-symbols
-
-
- 524 "Symbols currently being traced."
-
-
- 525 (atom #{}))
-
-
- 526
-
-
- 527 (defn traced?
-
-
- 528 "Return `true` iff `s` is a symbol currently being traced, else `nil`."
-
-
- 529 [s]
-
-
- 530 (try (contains? @traced-symbols s)
-
-
- 531 (catch Throwable _ nil)))
+ 531 (DEFLIST a-list 'EXPR))
532
- 533 (defn TRACE
+ 533 (defn SET
- 534 "Add this `s` to the set of symbols currently being traced. If `s`
+ 534 "Implementation of SET in Clojure. Add to the `oblist` a binding of the
- 535 is not a symbol or sequence of symbols, does nothing."
+ 535 value of `var` to the value of `val`. NOTE WELL: this is not SETQ!"
- 536 [s]
-
-
- 537 (swap! traced-symbols
-
-
- 538 #(cond
-
-
- 539 (symbol? s) (conj % s)
-
-
- 540 (and (seq? s) (every? symbol? s)) (union % (set s))
-
-
- 541 :else %)))
-
-
- 542
-
-
- 543 (defn UNTRACE
-
-
- 544 "Remove this `s` from the set of symbols currently being traced. If `s`
-
-
- 545 is not a symbol or sequence of symbols, does nothing."
-
-
- 546 [s]
-
-
- 547 (cond
-
-
- 548 (symbol? s) (swap! traced-symbols #(set (remove (fn [x] (= s x)) %)))
-
-
- 549 (and (seq? s) (every? symbol? s)) (map UNTRACE s))
-
-
- 550 @traced-symbols)
-
-
- 551
-
-
- 552 ;;;; Extensions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- 553
-
-
- 554 (defn DOC
-
-
- 555 "Open the page for this `symbol` in the Lisp 1.5 manual, if known, in the
-
-
- 556 default web browser.
-
-
- 557
-
-
- 558 **NOTE THAT** this is an extension function, not available in strct mode."
-
-
- 559 [symbol]
+ 536 [symbol val]
- 560 (when (lax? 'DOC)
-
-
- 561 (open-doc symbol)))
+ 537 (PUT symbol 'APVAL val))
- 562
+ 538
+
+
+ 539 ;;;; TRACE and friends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+ 540
- 563 (defn CONSP
+ 541 (def traced-symbols
- 564 "Return `T` if object `o` is a cons cell, else `F`.
+ 542 "Symbols currently being traced."
+
+
+ 543 (atom #{}))
+
+
+ 544
+
+
+ 545 (defn traced?
- 565
+ 546 "Return `true` iff `s` is a symbol currently being traced, else `nil`."
- 566 **NOTE THAT** this is an extension function, not available in strct mode.
+ 547 [s]
+
+
+ 548 (try (contains? @traced-symbols s)
- 567 I believe that Lisp 1.5 did not have any mechanism for testing whether an
+ 549 (catch Throwable _ nil)))
+
+
+ 550
+
+
+ 551 (defn TRACE
- 568 argument was, or was not, a cons cell."
+ 552 "Add this `s` to the set of symbols currently being traced. If `s`
- 569 [o]
+ 553 is not a symbol or sequence of symbols, does nothing."
+
+
+ 554 [s]
+
+
+ 555 (swap! traced-symbols
+
+
+ 556 #(cond
+
+
+ 557 (symbol? s) (conj % s)
+
+
+ 558 (and (seq? s) (every? symbol? s)) (union % (set s))
+
+
+ 559 :else %)))
+
+
+ 560
+
+
+ 561 (defn UNTRACE
+
+
+ 562 "Remove this `s` from the set of symbols currently being traced. If `s`
+
+
+ 563 is not a symbol or sequence of symbols, does nothing."
+
+
+ 564 [s]
+
+
+ 565 (cond
+
+
+ 566 (symbol? s) (swap! traced-symbols #(set (remove (fn [x] (= s x)) %)))
+
+
+ 567 (and (seq? s) (every? symbol? s)) (map UNTRACE s))
+
+
+ 568 @traced-symbols)
+
+
+ 569
+
+
+ 570 ;;;; Extensions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+ 571
+
+
+ 572 (defn DOC
+
+
+ 573 "Open the page for this `symbol` in the Lisp 1.5 manual, if known, in the
+
+
+ 574 default web browser.
+
+
+ 575
+
+
+ 576 **NOTE THAT** this is an extension function, not available in strct mode."
+
+
+ 577 [symbol]
+
+
+ 578 (when (lax? 'DOC)
+
+
+ 579 (open-doc symbol)))
+
+
+ 580
+
+
+ 581 (defn CONSP
+
+
+ 582 "Return `T` if object `o` is a cons cell, else `F`.
+
+
+ 583
+
+
+ 584 **NOTE THAT** this is an extension function, not available in strct mode.
+
+
+ 585 I believe that Lisp 1.5 did not have any mechanism for testing whether an
+
+
+ 586 argument was, or was not, a cons cell."
+
+
+ 587 [o]
- 570 (when (lax? 'CONSP)
+ 588 (when (lax? 'CONSP)
- 571 (if (instance? ConsCell o) 'T 'F)))
+ 589 (if (instance? ConsCell o) 'T 'F)))