Skip to content

Commit

Permalink
Revert "[lang] Uppercase call convention POC" and "fix tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
dustingetz committed Aug 23, 2024
1 parent 2f99c96 commit abd55dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
13 changes: 3 additions & 10 deletions src/hyperfiddle/electric/impl/lang_de2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,13 @@
(let [ns (-> env :ns :name), {:keys [line column]} (meta o)]
(str ns ":" line ":" column " " o)))

(defn electric-sym? [sym]
(let [s (name sym)]
(and (pos? (.length s))
(Character/isUpperCase (.charAt s 0)))))

(defn ?expand-macro [o env caller]
(if (symbol? (first o))
(let [o2 (?meta o (expand-macro env o))]
(if (identical? o o2)
(if (electric-sym? (first o))
(recur (?meta o (cons `e/$ o)) env caller)
(?meta o (cond->> (?meta o (list* (first o) (mapv (fn-> caller env) (rest o))))
(and (::trace env) (some-> (qualify-sym (first o) env) (traceable)))
(list `r/tracing (list 'quote (trace-crumb o env))))))
(?meta o (cond->> (?meta o (list* (first o) (mapv (fn-> caller env) (rest o))))
(and (::trace env) (some-> (qualify-sym (first o) env) (traceable)))
(list `r/tracing (list 'quote (trace-crumb o env)))))
(caller o2 env)))
(?meta o (list* (caller (first o) env) (mapv (fn-> caller env) (next o))))))

Expand Down
22 changes: 6 additions & 16 deletions test/hyperfiddle/electric_de_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,18 @@

#?(:clj
(tests "reactive doto"
(defn mutable-map [] (new java.util.HashMap))
(defn put-map [!m k v] (.put !m k v))
(defn a-ref [] (new Object))
(defn MutableMap [] (new java.util.HashMap))
(defn PutMap [!m k v] (.put !m k v))
(defn Ref [] (new Object))
(def !z (atom 0))
(def !xx (atom 0))
(with ((l/single {}
#_(doto (element "input")
(set-attribute! "type" "text")
(set-attribute! "value" x))
(tap (doto (mutable-map) ; the doto is incrementalized
(put-map "a" (swap! !z inc)) ; detect effect
(put-map "b" (tap (e/watch !xx)))))) tap tap)
(tap (doto (MutableMap) ; the doto is incrementalized
(PutMap "a" (swap! !z inc)) ; detect effect
(PutMap "b" (tap (e/watch !xx)))))) tap tap)
% := 0, % := {"a" 1 "b" 0}
(swap! !xx inc)
% := 1))) ; mutable map is clojure.core/=, therefore skipped
Expand Down Expand Up @@ -2263,13 +2263,3 @@
(l/single {} (loop [^java.util.Date x (java.util.Date.)] (.foo x)))
:ok := :ok
)

(e/defn CallMe ([] 0) ([n] n))

(tests "electric symbolic calling convention"
(with ((l/single {} (tap (CallMe))) tap tap)
% := 0))

(tests "electric symbolic calling convention"
(with ((l/single {} (tap (CallMe 10))) tap tap)
% := 10))

0 comments on commit abd55dc

Please sign in to comment.