From d352f11fc517d1d9328c6509ae322e8aa8ba879c Mon Sep 17 00:00:00 2001 From: xificurC Date: Tue, 14 May 2024 10:15:52 +0200 Subject: [PATCH] electric: fixes `e/amb` by propagating siting This worked `(do (e/server (d/pull db x)))` This didn't `(do (e/server (d/pull db x)) nil)` `(do a b)` expands to `(e/amb (e/drain a) b)`. `e/amb` wraps a and b into ctors. Ctors clear siting. This fix propagates the site into the ctors. --- src/hyperfiddle/electric_de.cljc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hyperfiddle/electric_de.cljc b/src/hyperfiddle/electric_de.cljc index acfd249ce..ab0c41c8a 100644 --- a/src/hyperfiddle/electric_de.cljc +++ b/src/hyperfiddle/electric_de.cljc @@ -22,6 +22,7 @@ (throw (ex-info (str "Electric code (" fn ") inside a Clojure function") (into {:electric-fn fn} (meta &form)))))) (defmacro ctor [expr] `(::lang/ctor ~expr)) +(defmacro sited-ctor [expr] `(::lang/ctor (::lang/site ~(::lang/current &env) ~expr))) (defmacro $ [F & args] `(check-electric $ (lang/$ ~F ~@args))) (defmacro frame [] @@ -107,7 +108,7 @@ Syntax : (amb table1 table2 ,,, tableN) ``` Returns the concatenation of `table1 table2 ,,, tableN`. -" [& exprs] `(::lang/call (join (i/fixed ~@(map #(list `r/invariant (list `ctor %)) exprs))))) +" [& exprs] `(::lang/call (join (i/fixed ~@(map #(list `r/invariant (list `sited-ctor %)) exprs))))) (defmacro input " Syntax :