Major overhaul of rule metadata, so upversioned to 0.3.0

Many tests do not pass at this stage
This commit is contained in:
Simon Brooke 2023-07-19 20:35:19 +01:00
parent 321e6edd9a
commit ff6bbad14c
2 changed files with 8 additions and 12 deletions

View file

@ -1,4 +1,4 @@
(defproject mw-engine "0.2.0-SNAPSHOT" (defproject mw-engine "0.3.0-SNAPSHOT"
:cloverage {:output "docs/cloverage"} :cloverage {:output "docs/cloverage"}
:codox {:metadata {:doc "**TODO**: write docs" :codox {:metadata {:doc "**TODO**: write docs"
:doc/format :markdown} :doc/format :markdown}

View file

@ -53,18 +53,14 @@
(defn apply-rule (defn apply-rule
"Apply a single `rule` to a `cell`. What this is about is that I want to be able, "Apply a single `rule` to a `cell`. What this is about is that I want to be able,
for debugging purposes, to tag a cell with the rule text of the rule which for debugging purposes, to tag a cell with the rule text of the rule which
fired (and especially so when an exception is thrown. So a rule may be either fired (and especially so when an exception is thrown). "
an ifn, or a list (ifn source-text). This function deals with despatching ;; as of version 0-3-0, metadata for rules is now passed around on the metadata
on those two possibilities. `world` is also passed in in order to be able ;; of the rule function itself. Yes, I know, this is obvious; but I'll confess
to access neighbours." ;; I didn't think of it before.
[world cell rule] [world cell rule]
(cond (let [result (apply rule (list cell world))]
(ifn? rule) (apply rule (list cell world))
(seq? rule) (let [[afn src lisp] rule
result (apply-rule world cell afn)]
(when result (when result
(merge result {:rule src (merge result (meta rule)))))
:lisp lisp})))))
(defn- apply-rules (defn- apply-rules
"Derive a cell from this `cell` of this `world` by applying these `rules`." "Derive a cell from this `cell` of this `world` by applying these `rules`."