242 lines
43 KiB
HTML
242 lines
43 KiB
HTML
<!DOCTYPE html PUBLIC ""
|
||
"">
|
||
<html><head><meta charset="UTF-8" /><title>beowulf</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><link rel="icon" type="image/x-icon" href="../img/beowulf_logo_favicon.png" /></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Beowulf</span> <span class="project-version">0.3.1-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="further_reading.html"><div class="inner"><span>Further Reading</span></div></a></li><li class="depth-1 current"><a href="intro.html"><div class="inner"><span>beowulf</span></div></a></li><li class="depth-1 "><a href="mexpr.html"><div class="inner"><span>Interpreting M-Expressions</span></div></a></li><li class="depth-1 "><a href="values.html"><div class="inner"><span>The properties of the system, and their values</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>beowulf</span></div></div></li><li class="depth-2 branch"><a href="beowulf.bootstrap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bootstrap</span></div></a></li><li class="depth-2 branch"><a href="beowulf.cons-cell.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>cons-cell</span></div></a></li><li class="depth-2 branch"><a href="beowulf.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 branch"><a href="beowulf.gendoc.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gendoc</span></div></a></li><li class="depth-2 branch"><a href="beowulf.host.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>host</span></div></a></li><li class="depth-2 branch"><a href="beowulf.interop.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>interop</span></div></a></li><li class="depth-2 branch"><a href="beowulf.io.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>io</span></div></a></li><li class="depth-2 branch"><a href="beowulf.manual.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>manual</span></div></a></li><li class="depth-2 branch"><a href="beowulf.oblist.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>oblist</span></div></a></li><li class="depth-2 branch"><a href="beowulf.read.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>read</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>reader</span></div></div></li><li class="depth-3 branch"><a href="beowulf.reader.char-reader.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>char-reader</span></div></a></li><li class="depth-3 branch"><a href="beowulf.reader.generate.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>generate</span></div></a></li><li class="depth-3 branch"><a href="beowulf.reader.macros.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>macros</span></div></a></li><li class="depth-3 branch"><a href="beowulf.reader.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li><li class="depth-3"><a href="beowulf.reader.simplify.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simplify</span></div></a></li><li class="depth-2"><a href="beowulf.scratch.html"><div class="inner"><span class="tree" style="top: -176px;"><span class="top" style="height: 185px;"></span><span class="bottom"></span></span><span>scratch</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#beowulf" id="beowulf"></a>beowulf</h1>
|
||
<h2><a href="#þý-liste-cræfte-spræc" id="þý-liste-cræfte-spræc"></a>Þý liste cræfte spræc</h2>
|
||
<p>LISP 1.5 is to all Lisp dialects as Beowulf is to English literature.</p>
|
||
<p><img src="https://simon-brooke.github.io/beowulf/docs/img/beowulf_logo_med.png" alt="Beowulf logo" /></p>
|
||
<h2><a href="#contents" id="contents"></a>Contents</h2>
|
||
<ul>
|
||
<li><a href="#what-this-is">What this is</a>
|
||
<ul>
|
||
<li><a href="#status">Status</a></li>
|
||
<li><a href="#but-why-----">BUT WHY?!!?!</a></li>
|
||
<li><a href="#project-target">Project Target</a></li>
|
||
<li><a href="#invoking">Invoking</a></li>
|
||
<li><a href="#building-and-invoking">Building and Invoking</a></li>
|
||
<li><a href="#reader-macros">Reader macros</a></li>
|
||
<li><a href="#functions-and-symbols-implemented">Functions and symbols implemented</a></li>
|
||
<li><a href="#architectural-plan">Architectural plan</a></li>
|
||
<li><a href="#resources-lisp15lsp">resources/lisp1.5.lsp</a></li>
|
||
<li><a href="#beowulf-boostrapclj">beowulf/boostrap.clj</a></li>
|
||
<li><a href="#beowulf-hostclj">beowulf/host.clj</a></li>
|
||
<li><a href="#beowulf-readclj">beowulf/read.clj</a></li>
|
||
<li><a href="#commentary">Commentary</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#installation">Installation</a>
|
||
<ul>
|
||
<li><a href="#input-output">Input/output</a></li>
|
||
<li><a href="#sysout">SYSOUT</a></li>
|
||
<li><a href="#sysin">SYSIN</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#learning-lisp-15">Learning Lisp 1.5</a></li>
|
||
<li><a href="#other-lisp-15-resources">Other Lisp 1.5 resources</a>
|
||
<ul>
|
||
<li><a href="#other-implementations">Other implmentations</a></li>
|
||
<li><a href="#history-resources">History resources</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#license">License</a></li>
|
||
</ul>
|
||
<p><small><i><a href="http://ecotrust-canada.github.io/markdown-toc/">Table of contents generated with markdown-toc</a></i></small></p>
|
||
<h2><a href="#what-this-is" id="what-this-is"></a>What this is</h2>
|
||
<p>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 bahaviour - except as documented below.</p>
|
||
<h3><a href="#but-why" id="but-why"></a>BUT WHY?!!?!</h3>
|
||
<p>Because.</p>
|
||
<p>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.</p>
|
||
<p>Because there is, so far as I know, no working implementation of Lisp 1.5 for modern machines.</p>
|
||
<p>Because I’m barking mad, and this is therapy.</p>
|
||
<h3><a href="#status" id="status"></a>Status</h3>
|
||
<p>Working Lisp interpreter, but some key features not yet implemented.</p>
|
||
<ul>
|
||
<li><a href="https://simon-brooke.github.io/beowulf/">Project website</a>.</li>
|
||
<li><a href="https://simon-brooke.github.io/beowulf/docs/codox/index.html">Source code documentation</a>.</li>
|
||
</ul>
|
||
<h3><a href="#project-target" id="project-target"></a>Project Target</h3>
|
||
<p>The project target is to be able to run the <a href="https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=52">Wang algorithm for the propositional calculus</a> given in chapter 8 of the <em>Lisp 1.5 Programmer’s Manual</em>. 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.</p>
|
||
<p>Some <code>readline</code>-like functionality would be really useful, but my attempt to integrate <a href="https://github.com/jline/jline3">JLine</a> has not (yet) been successful.</p>
|
||
<p>An in-core structure editor would be an extremely nice thing, and I may well implement one.</p>
|
||
<p>You are of course welcome to fork the project and do whatever you like with it!</p>
|
||
<h3><a href="#invoking" id="invoking"></a>Invoking</h3>
|
||
<p>Invoke with</p>
|
||
<pre><code>java -jar target/uberjar/beowulf-0.3.0-standalone.jar --help
|
||
</code></pre>
|
||
<p>(Obviously, check your version number)</p>
|
||
<p>Command line arguments as follows:</p>
|
||
<pre><code> -h, --help Print this message
|
||
-p PROMPT, --prompt PROMPT Set the REPL prompt to PROMPT
|
||
-r INITFILE, --read SYSOUTFILE Read Lisp sysout from the file SYSOUTFILE
|
||
(defaults to `resources/lisp1.5.lsp`)
|
||
-s, --strict Strictly interpret the Lisp 1.5 language,
|
||
without extensions.
|
||
</code></pre>
|
||
<p>To end a session, type <code>STOP</code> at the command prompt.</p>
|
||
<h3><a href="#building-and-invoking" id="building-and-invoking"></a>Building and Invoking</h3>
|
||
<p>Build with</p>
|
||
<pre><code>lein uberjar
|
||
</code></pre>
|
||
<h3><a href="#reader-macros" id="reader-macros"></a>Reader macros</h3>
|
||
<p>Currently <code>SETQ</code> and <code>DEFUN</code> are implemented as reader macros, sort of. It would now be possible to reimplement them as <code>FEXPRs</code> and so the reader macro functionality will probably go away.</p>
|
||
<h3><a href="#functions-and-symbols-implemented" id="functions-and-symbols-implemented"></a>Functions and symbols implemented</h3>
|
||
<table>
|
||
<thead>
|
||
<tr><th> Function </th><th> Type </th><th> Signature </th><th> Implementation </th><th> Documentation </th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td> NIL </td><td> Lisp variable </td><td> ? </td><td> </td><td> see manual pages <a href="#page22">22</a>, <a href="#page69">69</a> </td></tr>
|
||
<tr><td> T </td><td> Lisp variable </td><td> ? </td><td> </td><td> see manual pages <a href="#page22">22</a>, <a href="#page69">69</a> </td></tr>
|
||
<tr><td> F </td><td> Lisp variable </td><td> ? </td><td> </td><td> see manual pages <a href="#page22">22</a>, <a href="#page69">69</a> </td></tr>
|
||
<tr><td> ADD1 </td><td> Host lambda function </td><td> ? </td><td> </td><td> ? </td></tr>
|
||
<tr><td> AND </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> <code>T</code> if and only if none of my <code>args</code> evaluate to either <code>F</code> or <code>NIL</code>, else <code>F</code>. In <code>beowulf.host</code> principally because I don’t yet feel confident to define varargs functions in Lisp. </td></tr>
|
||
<tr><td> APPEND </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page11">11</a>, <a href="#page61">61</a> </td></tr>
|
||
<tr><td> APPLY </td><td> Host lambda function </td><td> ? </td><td> </td><td> Apply this <code>function</code> to these <code>arguments</code> in this <code>environment</code> and return the result. For bootstrapping, at least, a version of APPLY written in Clojure. All args are assumed to be symbols or <code>beowulf.cons-cell/ConsCell</code> objects. See page 13 of the Lisp 1.5 Programmers Manual. </td></tr>
|
||
<tr><td> ASSOC </td><td> Lisp lambda function, Host lambda function </td><td> ? </td><td> ? </td><td> 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 <code>beowulf.cons-cell/ConsCell</code> objects. See page 12 of the Lisp 1.5 Programmers Manual. <strong>NOTE THAT</strong> this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. </td></tr>
|
||
<tr><td> ATOM </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> Returns <code>T</code> if and only if the argument <code>x</code> is bound to an atom; else <code>F</code>. It is not clear to me from the documentation whether <code>(ATOM 7)</code> should return <code>T</code> or <code>F</code>. I’m going to assume <code>T</code>. </td></tr>
|
||
<tr><td> CAR </td><td> Host lambda function </td><td> ? </td><td> </td><td> Return the item indicated by the first pointer of a pair. NIL is treated specially: the CAR of NIL is NIL. </td></tr>
|
||
<tr><td> CAAAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CAAADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CAAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CAADAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CAADDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CAADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADDAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADDDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDAAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDAADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDADAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDADDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDAAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDADR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDDAR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDDDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDDR </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> CDR </td><td> Host lambda function </td><td> ? </td><td> </td><td> Return the item indicated by the second pointer of a pair. NIL is treated specially: the CDR of NIL is NIL. </td></tr>
|
||
<tr><td> CONS </td><td> Host lambda function </td><td> ? </td><td> </td><td> Construct a new instance of cons cell with this <code>car</code> and <code>cdr</code>. </td></tr>
|
||
<tr><td> CONSP </td><td> Host lambda function </td><td> ? </td><td> ? </td><td> Return <code>T</code> if object <code>o</code> is a cons cell, else <code>F</code>. <strong>NOTE THAT</strong> 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. </td></tr>
|
||
<tr><td> COPY </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page62">62</a> </td></tr>
|
||
<tr><td> DEFINE </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Bootstrap-only version of <code>DEFINE</code> which, post boostrap, can be overwritten in LISP. The single argument to <code>DEFINE</code> should be an association list of symbols to lambda functions. See page 58 of the manual. </td></tr>
|
||
<tr><td> DIFFERENCE </td><td> Host lambda function </td><td> ? </td><td> </td><td> ? </td></tr>
|
||
<tr><td> DIVIDE </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page26">26</a>, <a href="#page64">64</a> </td></tr>
|
||
<tr><td> DOC </td><td> Host lambda function </td><td> ? </td><td> ? </td><td> Open the page for this <code>symbol</code> in the Lisp 1.5 manual, if known, in the default web browser. <strong>NOTE THAT</strong> this is an extension function, not available in strct mode. </td></tr>
|
||
<tr><td> EFFACE </td><td> Lisp lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> see manual pages <a href="#page63">63</a> </td></tr>
|
||
<tr><td> ERROR </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Throw an error </td></tr>
|
||
<tr><td> EQ </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> Returns <code>T</code> if and only if both <code>x</code> and <code>y</code> are bound to the same atom, else <code>NIL</code>. </td></tr>
|
||
<tr><td> EQUAL </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> This is a predicate that is true if its two arguments are identical S-expressions, and false if they are different. (The elementary predicate <code>EQ</code> is defined only for atomic arguments.) The definition of <code>EQUAL</code> is an example of a conditional expression inside a conditional expression. NOTE: returns <code>F</code> on failure, not <code>NIL</code> </td></tr>
|
||
<tr><td> EVAL </td><td> Host lambda function </td><td> ? </td><td> </td><td> Evaluate this <code>expr</code> and return the result. If <code>environment</code> is not passed, it defaults to the current value of the global object list. The <code>depth</code> argument is part of the tracing system and should not be set by user code. All args are assumed to be numbers, symbols or <code>beowulf.cons-cell/ConsCell</code> objects. However, if called with just a single arg, <code>expr</code>, I’ll assume it’s being called from the Clojure REPL and will coerce the <code>expr</code> to <code>ConsCell</code>. </td></tr>
|
||
<tr><td> FACTORIAL </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> FIXP </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> ? </td></tr>
|
||
<tr><td> GENSYM </td><td> Host lambda function </td><td> ? </td><td> </td><td> Generate a unique symbol. </td></tr>
|
||
<tr><td> GET </td><td> Host lambda function </td><td> ? </td><td> </td><td> From the manual: ‘<code>get</code> is somewhat like <code>prop</code>; however its value is car of the rest of the list if the <code>indicator</code> is found, and NIL otherwise.’ It’s clear that <code>GET</code> is expected to be defined in terms of <code>PROP</code>, but we can’t implement <code>PROP</code> here because we lack <code>EVAL</code>; and we can’t have <code>EVAL</code> here because both it and <code>APPLY</code> depends on <code>GET</code>. OK, It’s worse than that: the statement of the definition of <code>GET</code> (and of) <code>PROP</code> on page 59 says that the first argument to each must be a list; But the in the definition of <code>ASSOC</code> on page 70, when <code>GET</code> is called its first argument is always an atom. Since it’s <code>ASSOC</code> and <code>EVAL</code> which I need to make work, I’m going to assume that page 59 is wrong. </td></tr>
|
||
<tr><td> GREATERP </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> ? </td></tr>
|
||
<tr><td> INTEROP </td><td> Host lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> INTERSECTION </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> LENGTH </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page62">62</a> </td></tr>
|
||
<tr><td> LESSP </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> ? </td></tr>
|
||
<tr><td> MAPLIST </td><td> Lisp lambda function </td><td> ? </td><td> FUNCTIONAL </td><td> see manual pages <a href="#page20">20</a>, <a href="#page21">21</a>, <a href="#page63">63</a> </td></tr>
|
||
<tr><td> MEMBER </td><td> Lisp lambda function </td><td> ? </td><td> PREDICATE </td><td> see manual pages <a href="#page11">11</a>, <a href="#page62">62</a> </td></tr>
|
||
<tr><td> MINUSP </td><td> Lisp lambda function </td><td> ? </td><td> PREDICATE </td><td> see manual pages <a href="#page26">26</a>, <a href="#page64">64</a> </td></tr>
|
||
<tr><td> NOT </td><td> Lisp lambda function </td><td> ? </td><td> PREDICATE </td><td> see manual pages <a href="#page21">21</a>, <a href="#page23">23</a>, <a href="#page58">58</a> </td></tr>
|
||
<tr><td> NULL </td><td> Lisp lambda function </td><td> ? </td><td> PREDICATE </td><td> see manual pages <a href="#page11">11</a>, <a href="#page57">57</a> </td></tr>
|
||
<tr><td> NUMBERP </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> ? </td></tr>
|
||
<tr><td> OBLIST </td><td> Host lambda function </td><td> ? </td><td> </td><td> Return a list of the symbols currently bound on the object list. <strong>NOTE THAT</strong> 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. </td></tr>
|
||
<tr><td> ONEP </td><td> Lisp lambda function </td><td> ? </td><td> PREDICATE </td><td> see manual pages <a href="#page26">26</a>, <a href="#page64">64</a> </td></tr>
|
||
<tr><td> OR </td><td> Host lambda function </td><td> ? </td><td> PREDICATE </td><td> <code>T</code> if and only if at least one of my <code>args</code> evaluates to something other than either <code>F</code> or <code>NIL</code>, else <code>F</code>. In <code>beowulf.host</code> principally because I don’t yet feel confident to define varargs functions in Lisp. </td></tr>
|
||
<tr><td> PAIR </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page60">60</a> </td></tr>
|
||
<tr><td> PAIRLIS </td><td> Lisp lambda function, Host lambda function </td><td> ? </td><td> ? </td><td> This function gives the list of pairs of corresponding elements of the lists <code>x</code> and <code>y</code>, and APPENDs this to the list <code>a</code>. 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 <code>beowulf.cons-cell/ConsCell</code> objects. See page 12 of the Lisp 1.5 Programmers Manual. <strong>NOTE THAT</strong> this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. </td></tr>
|
||
<tr><td> PLUS </td><td> Host lambda function </td><td> ? </td><td> </td><td> ? </td></tr>
|
||
<tr><td> PRETTY </td><td> </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> PRINT </td><td> </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> see manual pages <a href="#page65">65</a>, <a href="#page84">84</a> </td></tr>
|
||
<tr><td> PROG </td><td> Host nlambda function </td><td> ? </td><td> </td><td> The accursed <code>PROG</code> feature. See page 71 of the manual. Lisp 1.5 introduced <code>PROG</code>, 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, <code>PROG</code> is a variadic pseudo function called as a <code>FEXPR</code> (or possibly an <code>FSUBR</code>, 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 <code>GO</code> statement. <strong>GO:</strong> A <code>GO</code> statement takes the form of <code>(GO target)</code>, where <code>target</code> should be one of the symbols which occur at top level among that particular invocation of <code>PROG</code>s arguments. A <code>GO</code> statement may occur at top level in a PROG, or in a clause of a <code>COND</code> statement in a <code>PROG</code>, but not in a function called from the <code>PROG</code> statement. When a <code>GO</code> 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 <code>A6</code> should be thrown. <strong>RETURN:</strong> A <code>RETURN</code> statement takes the form <code>(RETURN value)</code>, where <code>value</code> is any value. Following the evaluation of a <code>RETURN</code> statement, the <code>PROG</code> should immediately exit without executing any further expressions, returning the value. <strong>SET and SETQ:</strong> In addition to the above, if a <code>SET</code> or <code>SETQ</code> expression is encountered in any expression within the <code>PROG</code> body, it should affect not the global object list but instead only the local variables of the program. <strong>COND:</strong> In <strong>strict</strong> mode, when in normal execution, a <code>COND</code> statement none of whose clauses match should not return <code>NIL</code> but should throw an error with the code <code>A3</code>… <em>except</em> that inside a <code>PROG</code> body, it should not do so. <em>sigh</em>. <strong>Flow of control:</strong> Apart from the exceptions specified above, expressions in the program body are evaluated sequentially. If execution reaches the end of the program body, <code>NIL</code> is returned. Got all that? Good. </td></tr>
|
||
<tr><td> PROP </td><td> Lisp lambda function </td><td> ? </td><td> FUNCTIONAL </td><td> see manual pages <a href="#page59">59</a> </td></tr>
|
||
<tr><td> QUOTE </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page10">10</a>, <a href="#page22">22</a>, <a href="#page71">71</a> </td></tr>
|
||
<tr><td> QUOTIENT </td><td> Host lambda function </td><td> ? </td><td> </td><td> I’m not certain from the documentation whether Lisp 1.5 <code>QUOTIENT</code> returned the integer part of the quotient, or a realnum representing the whole quotient. I am for now implementing the latter. </td></tr>
|
||
<tr><td> RANGE </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> READ </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> An implementation of a Lisp reader sufficient for bootstrapping; not necessarily the final Lisp reader. <code>input</code> should be either a string representation of a LISP expression, or else an input stream. A single form will be read. </td></tr>
|
||
<tr><td> REMAINDER </td><td> Host lambda function </td><td> ? </td><td> </td><td> ? </td></tr>
|
||
<tr><td> REPEAT </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> RPLACA </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Replace the CAR pointer of this <code>cell</code> with this <code>value</code>. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) </td></tr>
|
||
<tr><td> RPLACD </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Replace the CDR pointer of this <code>cell</code> with this <code>value</code>. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) </td></tr>
|
||
<tr><td> SEARCH </td><td> Lisp lambda function </td><td> ? </td><td> FUNCTIONAL </td><td> see manual pages <a href="#page63">63</a> </td></tr>
|
||
<tr><td> SET </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Implementation of SET in Clojure. Add to the <code>oblist</code> a binding of the value of <code>var</code> to the value of <code>val</code>. NOTE WELL: this is not SETQ! </td></tr>
|
||
<tr><td> SUB1 </td><td> Lisp lambda function, Host lambda function </td><td> ? </td><td> </td><td> ? </td></tr>
|
||
<tr><td> SUB2 </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> SUBLIS </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page12">12</a>, <a href="#page61">61</a> </td></tr>
|
||
<tr><td> SUBST </td><td> Lisp lambda function </td><td> ? </td><td> </td><td> see manual pages <a href="#page11">11</a>, <a href="#page61">61</a> </td></tr>
|
||
<tr><td> SYSIN </td><td> Host lambda function </td><td> ? </td><td> ? </td><td> Read the contents of the file at this <code>filename</code> 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. <strong>NOTE THAT</strong> if the provided <code>filename</code> does not end with <code>.lsp</code> (which, if you’re writing it from the Lisp REPL, it won’t), the extension <code>.lsp</code> will be appended. <strong>NOTE THAT</strong> this is an extension function, not available in strct mode. </td></tr>
|
||
<tr><td> SYSOUT </td><td> Host lambda function </td><td> ? </td><td> ? </td><td> Dump the current content of the object list to file. If no <code>filepath</code> is specified, a file name will be constructed of the symbol <code>Sysout</code> and the current date. File paths will be considered relative to the filepath set when starting Lisp. <strong>NOTE THAT</strong> this is an extension function, not available in strct mode. </td></tr>
|
||
<tr><td> TERPRI </td><td> </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> see manual pages <a href="#page65">65</a>, <a href="#page84">84</a> </td></tr>
|
||
<tr><td> TIMES </td><td> Host lambda function </td><td> ? </td><td> </td><td> ? </td></tr>
|
||
<tr><td> TRACE </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Add this <code>s</code> to the set of symbols currently being traced. If <code>s</code> is not a symbol or sequence of symbols, does nothing. </td></tr>
|
||
<tr><td> UNION </td><td> Lisp lambda function </td><td> ? </td><td> ? </td><td> ? </td></tr>
|
||
<tr><td> UNTRACE </td><td> Host lambda function </td><td> ? </td><td> PSEUDO-FUNCTION </td><td> Remove this <code>s</code> from the set of symbols currently being traced. If <code>s</code> is not a symbol or sequence of symbols, does nothing. </td></tr>
|
||
<tr><td> ZEROP </td><td> Lisp lambda function </td><td> ? </td><td> PREDICATE </td><td> see manual pages <a href="#page26">26</a>, <a href="#page64">64</a> </td></tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Functions described as ‘Lisp function’ above are defined in the default sysout file, <code>resources/lisp1.5.lsp</code>, which will be loaded by default unless you specify another initfile on the command line.</p>
|
||
<p>Functions described as ‘Host function’ are implemented in Clojure, but if you’re brave you can redefine them in Lisp and the Lisp definitions will take precedence over the Clojure implementations.</p>
|
||
<h3><a href="#architectural-plan" id="architectural-plan"></a>Architectural plan</h3>
|
||
<p>Not everything documented in this section is yet built. It indicates the direction of travel and intended destination, not the current state.</p>
|
||
<h4><a href="#resourceslisp15lsp" id="resourceslisp15lsp"></a>resources/lisp1.5.lsp</h4>
|
||
<p>The objective is to have within <code>resources/lisp1.5.lsp</code>, all those functions defined in the Lisp 1.5 Programmer’s Manual which can be implemented in Lisp.</p>
|
||
<p>This means that, while Beowulf is hosted on Clojure, all that would be required to rehost Lisp 1.5 on a different platform would be to reimplement</p>
|
||
<ul>
|
||
<li>bootstrap.clj</li>
|
||
<li>host.clj</li>
|
||
<li>read.clj</li>
|
||
</ul>
|
||
<p>The objective this is to make it fairly easy to implement Lisp 1.5 on top of any of the many <a href="https://github.com/kanaka/mal">Make A Lisp</a> implementations.</p>
|
||
<h4><a href="#beowulfboostrapclj" id="beowulfboostrapclj"></a>beowulf/boostrap.clj</h4>
|
||
<p>This file is essentially Lisp as defined in Chapter 1 (pages 1-14) of the Lisp 1.5 Programmer’s Manual; that is to say, a very simple Lisp language, which should, I believe, be sufficient in conjunction with the functions provided by <code>beowulf.host</code>, to bootstrap the full Lisp 1.5 interpreter.</p>
|
||
<p>In addition it contains the function <code>INTEROP</code>, which allows host language functions to be called from Lisp.</p>
|
||
<h4><a href="#beowulfhostclj" id="beowulfhostclj"></a>beowulf/host.clj</h4>
|
||
<p>This file provides Lisp 1.5 functions which can’t be (or can’t efficiently be) implemented in Lisp 1.5, which therefore need to be implemented in the host language, in this case Clojure.</p>
|
||
<h4><a href="#beowulfreadclj" id="beowulfreadclj"></a>beowulf/read.clj</h4>
|
||
<p>This file provides the reader required for boostrapping. It’s not a bad reader - it provides feedback on errors found in the input - but it isn’t the real Lisp reader.</p>
|
||
<p>Intended deviations from the behaviour of the real Lisp reader are as follows:</p>
|
||
<ol>
|
||
<li>It reads the meta-expression language <code>MEXPR</code> in addition to the symbolic expression language <code>SEXPR</code>, which I do not believe the Lisp 1.5 reader ever did;</li>
|
||
<li>It treats everything between a double semi-colon and an end of line as a comment, as most modern Lisps do; but I do not believe Lisp 1.5 had this feature.</li>
|
||
</ol>
|
||
<h3><a href="#commentary" id="commentary"></a>Commentary</h3>
|
||
<p>What’s surprised me in working on this is how much more polished Lisp 1.5 is than legend had led me to believe. The language is remarkably close to <a href="http://www.softwarepreservation.org/projects/LISP/standard_lisp_family/#Portable_Standard_LISP_">Portable Standard Lisp</a> which is in my opinion one of the best and most usable early Lisp implementations.</p>
|
||
<p>What’s even more surprising is how faithful a reimplementation of Lisp 1.5 the first Lisp dialect I learned, <a href="https://en.wikipedia.org/wiki/Acornsoft_LISP">Acornsoft Lisp</a>, turns out to have been.</p>
|
||
<p>I’m convinced you could still use Lisp 1.5 for interesting and useful software (which isn’t to say that modern Lisps aren’t better, but this is software which is almost sixty years old).</p>
|
||
<h2><a href="#installation" id="installation"></a>Installation</h2>
|
||
<p>Download the latest <a href="https://github.com/simon-brooke/beowulf/releases">release ‘uberjar’</a> and run it using:</p>
|
||
<pre><code class="language-bash"> java -jar <path name of uberjar>
|
||
</code></pre>
|
||
<p>Or clone the source and build it using:</p>
|
||
<pre><code class="language-bash"> lein uberjar`
|
||
</code></pre>
|
||
<p>To build it you will require to have <a href="https://leiningen.org/">Leiningen</a> installed.</p>
|
||
<h3><a href="#inputoutput" id="inputoutput"></a>Input/output</h3>
|
||
<p>Lisp 1.5 greatly predates modern computers. It had a facility to print to a line printer, or to punch cards on a punch-card machine, and it had a facility to read system images in from tape; but there’s no file I/O as we would currently understand it, and, because there are no character strings and the valid characters within an atom are limited, it isn’t easy to compose a sensible filename.</p>
|
||
<p>I’ve provided two functions to work around this problem.</p>
|
||
<h4><a href="#sysout" id="sysout"></a>SYSOUT</h4>
|
||
<p><code>SYSOUT</code> dumps the global object list to disk as a single S Expression (specifically: an association list). This allows you to persist your session, with all your current work, to disk. The function takes one argument, expected to be a symbol, and, if that argument is provided, writes a file whose name is that symbol with <code>.lsp</code> appended. If no argument is provided, it will construct a filename comprising the token <code>Sysout</code>, followed by the current date, followed by <code>.lsp</code>. In either case the file will be written to the directory given in the FILEPATH argument at startup time, or by default the current directory.</p>
|
||
<p>Obviously, <code>SYSOUT</code> may be called interactively (and this is the expected practice).</p>
|
||
<h4><a href="#sysin" id="sysin"></a>SYSIN</h4>
|
||
<p><code>SYSIN</code> reads a file from disk and overwrites the global object list with its contents. The expected practice is that this will be a file created by <code>SYSOUT</code>. A command line flag <code>--read</code> is provided so that you can specify</p>
|
||
<h2><a href="#learning-lisp-15" id="learning-lisp-15"></a>Learning Lisp 1.5</h2>
|
||
<p>The <code>Lisp 1.5 Programmer's Manual</code> is still <a href="https://mitpress.mit.edu/books/lisp-15-programmers-manual">in print, ISBN 13 978-0-262-13011-0</a>; but it’s also <a href="http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf">available online</a>.</p>
|
||
<h2><a href="#other-lisp-15-resources" id="other-lisp-15-resources"></a>Other Lisp 1.5 resources</h2>
|
||
<p>The main resource I’m aware of is the Software Preservation Society’s site, <a href="http://www.softwarepreservation.org/projects/LISP/lisp1.5">here</a>. It has lots of fascinating stuff including full assembler listings for various obsolete processors, but I failed to find the Lisp source of Lisp functions as a text file, which is why <code>resources/lisp1.5.lsp</code> is largely copytyped and reconstructed from the manual.</p>
|
||
<h3><a href="#other-implementations" id="other-implementations"></a>Other implementations</h3>
|
||
<p>There’s an online (browser native) Lisp 1.5 implementation <a href="https://pages.zick.run/ichigo/">here</a> (source code <a href="https://github.com/zick/IchigoLisp">here</a>). It even has a working compiler!</p>
|
||
<h3><a href="#history-resources" id="history-resources"></a>History resources</h3>
|
||
<p>I’m compiling a <a href="https://simon-brooke.github.io/beowulf/docs/further_reading.html">list of links to historical documents on Lisp 1.5</a>.</p>
|
||
<h2><a href="#license" id="license"></a>License</h2>
|
||
<p>Copyright © 2019 Simon Brooke. Licensed under the GNU General Public License, version 2.0 or (at your option) any later version.</p>
|
||
</div></div></div></body></html> |