This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-10
Channels
- # announcements (10)
- # aws (5)
- # babashka (81)
- # babashka-sci-dev (4)
- # beginners (100)
- # calva (60)
- # clj-kondo (34)
- # clojars (1)
- # clojure (30)
- # clojure-austin (12)
- # clojure-berlin (1)
- # clojure-europe (45)
- # clojure-italy (5)
- # clojure-losangeles (9)
- # clojure-nl (3)
- # clojure-norway (10)
- # clojure-spec (1)
- # clojurescript (8)
- # community-development (2)
- # conjure (5)
- # cursive (10)
- # data-science (2)
- # datalog (1)
- # emacs (4)
- # events (10)
- # fulcro (6)
- # jobs-discuss (8)
- # lambdaisland (3)
- # leiningen (2)
- # luminus (5)
- # membrane (61)
- # off-topic (8)
- # portal (5)
- # releases (20)
- # sci (25)
- # scittle (6)
- # shadow-cljs (25)
- # testing (6)
- # xtdb (11)
Can anyone point to some code that has #C015LCR9MHD AND #C03S1KBA2 / #C03S1L9DN compatible macros? Is there an easy trick to it? For instance, writing macros for #C015LCR9MHD requires writing a ^:sci/macro
function, whereas for normal clj/cljs it requires a normal macro written in clj. There's no #?(:sci ...)
.cljc reader conditional (as far as I am aware (yet)). So curious if there is a best practice here to ship a library that is sci/#CLX41ASCS / #C03S1KBA2 / #C03S1L9DN compatible?
@goomba It depends what you want to achieve. In bb and clojure there are no differences between macros
But since there is no guarantee that a macro exists as a compiled thing in JS once you compiled your CLJS you often have to copy the macro code to a .cljs
file if you want to configure it to work with SCI as pre-compiled macros. There is AFAIK no way around this.
So this is the config for promesa, which is a macro-heavy library: https://github.com/babashka/sci.configs/blob/main/src/sci/configs/funcool/promesa.cljs This configured is re-used in #scittle and #nbb and some other projects
Interesting. Now something like this: https://github.com/babashka/sci.configs/blob/main/src/sci/configs/funcool/promesa.cljs#L143 I'm assuming that will be treated like a regular function in a non sci context?
worrrd
ok that makes that easy
just write all macros like that
I am a little unclear how macros work in sci with cljs.
(def do-twice ^:sci/macro (fn [_&form _&env x] (list 'do x x)))
That seems okay, but:
(sci/eval-string "(do-twice (f))" {:bindings {'do-twice do-twice 'f #(println "hello")}})
I can see how that would work with one use of do-twice in the eval string, but what if there is more than one?