This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-09
Channels
- # announcements (16)
- # beginners (86)
- # calva (4)
- # cider (17)
- # circleci (1)
- # clj-kondo (4)
- # cljs-dev (12)
- # cljsrn (4)
- # clojure (82)
- # clojure-europe (2)
- # clojure-houston (4)
- # clojure-italy (5)
- # clojure-nl (7)
- # clojure-spec (49)
- # clojure-uk (19)
- # clojurescript (76)
- # core-async (7)
- # cursive (1)
- # data-science (4)
- # datomic (5)
- # figwheel (1)
- # fulcro (10)
- # graalvm (15)
- # jobs (1)
- # juxt (6)
- # kaocha (2)
- # leiningen (5)
- # random (2)
- # shadow-cljs (25)
- # sql (5)
- # tools-deps (113)
- # vim (3)
- # yada (14)
I am confused by the definition of function js-obj in cljs.core. The 0 arity looks like a recursive call to me, but it certainly returns quickly without infinitely recursing. Is someone familiar with what is going on there?
Here is the defn for quick reference:
(defn js-obj
"Create JavaSript object from an even number arguments representing
interleaved keys and values."
([]
(cljs.core/js-obj))
([& keyvals]
(apply gobject/create keyvals)))
Maybe that is dead code?
When I try to declare my own similar function, it does call the 0 arity, and recurses infinitely. Hmmm.
@andy.fingerhut see https://blog.fikesfarm.com/posts/2016-03-01-clojurescript-macro-sugar.html cljs.core/js-obj is also a macro which will used first
ah, that makes sense then why I couldn't find it in the same source file with the defn of js-obj.
@andy.fingerhut this is a difference from Clojure
I've coined the term "macro-function" https://blog.fikesfarm.com/posts/2015-12-12-clojurescript-macro-functions.html
^ That's non-normative, we have formal language in https://clojurescript.org/about/differences#_macros FWIW