Actually, this isn't right (still) but too tired to continue.
I'm backporting expectations from more modern Lisps onto Lisp 1.5; GET does not work the way I expect.
This commit is contained in:
parent
64a27be8e5
commit
b5afb1ad44
|
@ -424,6 +424,10 @@
|
||||||
(make-beowulf-list (map CAR @oblist))
|
(make-beowulf-list (map CAR @oblist))
|
||||||
NIL))
|
NIL))
|
||||||
|
|
||||||
|
(def ^:private magic-marker
|
||||||
|
"The unexplained magic number which marks the start of a property list."
|
||||||
|
(Integer/parseInt "777778" 8))
|
||||||
|
|
||||||
(defn PUT
|
(defn PUT
|
||||||
"Put this `value` as the value of the property indicated by this `indicator`
|
"Put this `value` as the value of the property indicated by this `indicator`
|
||||||
of this `symbol`. Return `value` on success.
|
of this `symbol`. Return `value` on success.
|
||||||
|
@ -431,7 +435,6 @@
|
||||||
NOTE THAT there is no `PUT` defined in the manual, but it would have been
|
NOTE THAT there is no `PUT` defined in the manual, but it would have been
|
||||||
easy to have defined it so I don't think this fully counts as an extension."
|
easy to have defined it so I don't think this fully counts as an extension."
|
||||||
[symbol indicator value]
|
[symbol indicator value]
|
||||||
(let [magic-marker (Integer/parseInt "777778" 8)]
|
|
||||||
(if-let [binding (ASSOC symbol @oblist)]
|
(if-let [binding (ASSOC symbol @oblist)]
|
||||||
(if-let [prop (ASSOC indicator (CDDR binding))]
|
(if-let [prop (ASSOC indicator (CDDR binding))]
|
||||||
(RPLACD prop value)
|
(RPLACD prop value)
|
||||||
|
@ -447,12 +450,36 @@
|
||||||
(make-cons-cell
|
(make-cons-cell
|
||||||
(make-beowulf-list (list s magic-marker p v))
|
(make-beowulf-list (list s magic-marker p v))
|
||||||
ob))
|
ob))
|
||||||
symbol indicator value))))
|
symbol indicator value)))
|
||||||
|
|
||||||
|
(defn GET
|
||||||
|
"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 it depends on `GET`."
|
||||||
|
[symbol indicator]
|
||||||
|
(let [binding (ASSOC symbol @oblist)]
|
||||||
|
(cond
|
||||||
|
(= binding NIL) NIL
|
||||||
|
(= magic-marker (CADR binding)) (loop [b binding]
|
||||||
|
(cond (= b NIL) NIL
|
||||||
|
(= (CAR b) indicator) (CADR b)
|
||||||
|
:else (recur (CDR b))))
|
||||||
|
:else (throw
|
||||||
|
(ex-info "Misformatted property list (missing magic marker)"
|
||||||
|
{:phase :host
|
||||||
|
:function :get
|
||||||
|
:args (list symbol indicator)
|
||||||
|
:type :beowulf})))))
|
||||||
|
|
||||||
(defn DEFLIST
|
(defn DEFLIST
|
||||||
"For each pair in this association list `a-list`, set the property with this
|
"For each pair in this association list `a-list`, set the property with this
|
||||||
`indicator` of the symbol which is the first element of the pair to the
|
`indicator` of the symbol which is the first element of the pair to the
|
||||||
value which is the second element of the pair."
|
value which is the second element of the pair. See page 58 of the manual."
|
||||||
[a-list indicator]
|
[a-list indicator]
|
||||||
(map
|
(map
|
||||||
#(PUT (CAR %) indicator (CDR %))
|
#(PUT (CAR %) indicator (CDR %))
|
||||||
|
@ -463,7 +490,7 @@
|
||||||
in LISP.
|
in LISP.
|
||||||
|
|
||||||
The single argument to `DEFINE` should be an association list of symbols to
|
The single argument to `DEFINE` should be an association list of symbols to
|
||||||
lambda functions"
|
lambda functions. See page 58 of the manual."
|
||||||
[a-list]
|
[a-list]
|
||||||
(DEFLIST a-list 'EXPR))
|
(DEFLIST a-list 'EXPR))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue