diff --git a/src/cljs/emptyhead/newlib/delegate.cljs b/src/cljs/emptyhead/newlib/delegate.cljs index 32f73dd..ce40e19 100644 --- a/src/cljs/emptyhead/newlib/delegate.cljs +++ b/src/cljs/emptyhead/newlib/delegate.cljs @@ -13,6 +13,13 @@ (let [remover (thought/register-thought! [:EH :CORE :NOP] :ext-stages [[:EH :MSG :REMOVE-DELEGATE msg del]])] (eval/execute! remover))) + +;; Forget idea stored in `thought`'s data. Used to make destructors. +(def/define! [:EH :IDEA :FORGET] + (fn [thought parent] + (idea/forget-idea! (thought/data thought)) + [parent nil])) + ;; FIXME Delegate order is currently undefined! Give this a proper order. ;; FIXME needs to be called with a list as second arg?? (defn add-delegate @@ -34,6 +41,5 @@ [msg] (let [stage [:EH :MSG :DELEGATE msg] dels (-> (thought/register-thought! [:EH :CORE :CONTAINER] :ext-stages [stage]) - eval/execute! thought/pop-stack second)] - (mapcat #(cons % (get-delegates %)) dels) - )) + eval/execute! thought/empty-stack second)] + (mapcat #(cons % (get-delegates %)) dels))) diff --git a/src/cljs/emptyhead/newlib/math/arithmetic.cljs b/src/cljs/emptyhead/newlib/math/arithmetic.cljs index e9a673d..0eaf5e4 100644 --- a/src/cljs/emptyhead/newlib/math/arithmetic.cljs +++ b/src/cljs/emptyhead/newlib/math/arithmetic.cljs @@ -16,7 +16,7 @@ th (thought/register-thought! [:EH :IO :RETURN] :data to :reference (str "<" to "+_>"))] - (del/add-delegate th [[:EH :PRIM :PARTIAL :+]]) + (del/add-delegate th [:EH :PRIM :PARTIAL :+]) (extend/register-extension! th [th]) [parent th]))) @@ -28,7 +28,7 @@ th (thought/register-thought! [:EH :IO :RETURN] :data [to from] :reference (str "<" to "+" from ">"))] - (del/add-delegate th [[:EH :LAZY [:EH :PRIM :NUM]]]) + (del/add-delegate th [:EH :LAZY [:EH :PRIM :NUM]]) (extend/register-extension! th [th]) [parent th]))) @@ -39,7 +39,7 @@ from (if (symbol? from) (msg/apply-msg to [:EH :REIFY]) from)] [parent (+ to from)]))) -(del/add-delegate [:EH :LAZY [:EH :PRIM :NUM]] [[:EH :PRIM :NUM]]) +(del/add-delegate [:EH :LAZY [:EH :PRIM :NUM]] [:EH :PRIM :NUM]) (thought/register-singleton! [:EH :PRIM :PARTIAL :+ [:EH :PRIM :NUM]]) (msg/register-single-impl [:EH :PRIM :PARTIAL :+] [:EH :PRIM :NUM] [:EH :PRIM :PARTIAL :+ [:EH :PRIM :NUM]]) diff --git a/src/cljs/emptyhead/newlib/scratch.cljs b/src/cljs/emptyhead/newlib/scratch.cljs index 8b3d8b9..a73548c 100644 --- a/src/cljs/emptyhead/newlib/scratch.cljs +++ b/src/cljs/emptyhead/newlib/scratch.cljs @@ -8,4 +8,4 @@ [emptyhead.newlib.math.number])) ;; XXX why does the second arg need to be wrapped like this? -(del/add-delegate :! [[:EH :REIFY]]) +(del/add-delegate :! [:EH :REIFY])