more cleanups & docs

This commit is contained in:
2025-08-10 17:02:47 +02:00
parent d278185ff3
commit 3ed6bafa84
10 changed files with 54 additions and 25 deletions

View File

@@ -8,15 +8,13 @@
(defn make-thought
"Helper function to make thought object.
You may want `register-thought!` instead."
[operator & {:keys [data ext-contract ext-stages]
:or {data {} ext-contract {}
[operator & {:keys [data ext-stages]
:or {data {}
ext-stages [[:PRE-EXECUTE] [:EXECUTE] [:POST-EXECUTE]]}}]
(hash-map :operator operator
:data data
:ext-contract ext-contract
:ext-stages ext-stages
:return []
:transient nil))
:return []))
(defn register-thought!
"Create a thought and register it in the state.

View File

@@ -6,7 +6,7 @@
[emptyhead.idea.memtag :as memtag]
[emptyhead.idea.protocol :as prtc]))
(defn register-implementation!
(defn- register-implementation!
[operator impl]
(let [impl-prop (magic/thought-impl-prop operator)]
(idea/have-idea! :prefix (str "impl_thought#" (magic/symbolize-ns operator))
@@ -14,7 +14,8 @@
:shadowing [impl-prop]
:data {:implementation impl})))
(defn register-constructor!
; TODO add documentation / elaborate on this whole constr-fn stuff
(defn- register-constructor!
[operator & {:keys [constr-fn defaults]
:or {constr-fn (fn [thought parent] {})
defaults {}}}]
@@ -34,6 +35,8 @@
(constr-fn thought parent))))])))))
(defn define!
"Define a new kind of thought, with its operator name and implementation.
TODO explain what constr-fn and defaults does"
[operator impl & {:keys [constr-fn defaults]
:as constr-args}]
(register-implementation! operator impl)

View File

@@ -1,6 +1,5 @@
(ns emptyhead.thought.extend
(:require [emptyhead.contract.eval :as contract]
[emptyhead.idea.property :as prop]
(:require [emptyhead.idea.property :as prop]
[emptyhead.idea.protocol :as prtc]
[emptyhead.thought.crud :as thought]
[emptyhead.util.magic :as magic]