hyperfiddle

2025-04-01T20:19:22.209289Z

This isn’t at all urgent, but I’m seeing something odd with lambdas in the operator position of a call. Details in thread.

2025-04-01T20:20:05.711199Z

(e/defn Main []
  (e/server
    (let [F (e/fn [& _]
              (e/server (/ 1 0)))]
      (F))))
…gives a divide-by-zero error as expected. But if I refactor, moving the lambda to the operator position of the call…
(e/defn Main []
  (e/server
    ((e/fn [& _]
       (e/server (/ 1 0))))))
…that gives: Wrong number of args (0) passed to: clojure.lang.PersistentHashMap If I pass a single argument like this…
(e/defn Main []
  (e/server
    ((e/fn [& _]
       (e/server (/ 1 0)))
     1)))
…it returns nil.

Dustin Getz (Hyperfiddle) 2025-04-01T20:22:25.830899Z

you can't call an e/fn like that, you need to use e/call

Dustin Getz (Hyperfiddle) 2025-04-01T20:23:21.819519Z

electric sees this as a clojure function call, it doesn't know that the object being called is an e/fn because the call is anonymous, i.e., it isn't a capitalized name

2025-04-01T20:24:53.728599Z

Ah, OK. Thanks.