cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
dnolen 2019-08-09T00:10:47.025Z

it should really be disallowed in all cases where it cannot possibly be a method call

dnolen 2019-08-09T00:11:29.025200Z

well dot form really

2019-08-09T07:13:24.026600Z

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?

2019-08-09T07:16:09.026900Z

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)))

2019-08-09T07:17:50.028400Z

Maybe that is dead code?

2019-08-09T07:29:53.029100Z

When I try to declare my own similar function, it does call the 0 arity, and recurses infinitely. Hmmm.

thheller 2019-08-09T10:39:15.029700Z

@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

2019-08-09T10:47:23.031Z

ah, that makes sense then why I couldn't find it in the same source file with the defn of js-obj.

dnolen 2019-08-09T13:01:06.031300Z

@andy.fingerhut this is a difference from Clojure

dnolen 2019-08-09T13:01:15.031700Z

ClojureScript macros and fns can have the same name

mfikes 2019-08-09T15:03:13.032100Z

I've coined the term "macro-function" https://blog.fikesfarm.com/posts/2015-12-12-clojurescript-macro-functions.html

mfikes 2019-08-09T15:05:31.032700Z

^ That's non-normative, we have formal language in https://clojurescript.org/about/differences#_macros FWIW