Skip to content

Commit

Permalink
electric: fixes e/amb by propagating siting
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xificurC committed May 14, 2024
1 parent 2eb0974 commit d352f11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hyperfiddle/electric_de.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down Expand Up @@ -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 :
Expand Down

0 comments on commit d352f11

Please sign in to comment.