This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-12
Channels
- # admin-announcements (56)
- # beginners (67)
- # boot (159)
- # cider (5)
- # cljs-dev (16)
- # cljsjs (7)
- # clojure (142)
- # clojure-dev (15)
- # clojure-japan (1)
- # clojure-poland (1)
- # clojure-russia (33)
- # clojurebridge (2)
- # clojurecup (1)
- # clojurescript (56)
- # cursive (3)
- # datavis (2)
- # datomic (29)
- # devops (6)
- # editors (1)
- # emacs (3)
- # hoplon (95)
- # ldnclj (15)
- # leiningen (18)
- # off-topic (10)
- # om (12)
- # onyx (7)
- # parinfer (6)
- # proton (1)
- # spacemacs (3)
- # yada (2)
@richiardiandrea: how did you do all of those things?
they are all just compiler flags...except dump core that is described, we followed -> https://github.com/clojure/clojurescript/wiki/Optional-Self-hosting
note that this is required just for bootstrapped cljs...as we cannot use :optimizations :advanced
David recently referred to an interesting feature https://clojurians.slack.com/archives/clojurescript/p1449702186005954 and here is a demo of what it looks like https://gist.github.com/mfikes/567c85c6473f2c4b511b partially working. It could be cool if it pans out.
I want to write an article with embedded cljs repl so that readers can run and modify code listings
what should I use for that? is there some state of the art embeddable repl lib for cljs in cljs or do I have to roll my own?
think this is aimed at that sort of use https://github.com/ScalaConsultants/replumb
Is it possible for a clojurescript macro to call a function? I'm asking because I'm surprised but the error I'm getting with this simple code:
(defn foo []
(println "foo"))
(defmacro call-foo "call foo"
[]
`(foo))
When running my tests (phantomjs) I get the following:
ERROR in (foo-test) (at cljs$lang$test (file:13:17)
Uncaught exception, not in assertion.
expected: nil
actual: #object[TypeError TypeError: undefined is not an object (evaluating 'juxt.iota.foo')]
Ran 1 tests containing 1 assertions.
0 failures, 1 errors.
Subprocess failed
The ns is juxt.iota
yes, that may be it - how do I quote the function?
I don't usually write macros in clojurescript projects, but I'm trying to write tests for juxt.iota which is based on macros
Well, you can call Clojure functions during macroexpansion, but you can't emit them in the quoted form - Clojurescript won't see Clojure code after all.
You have to define the function you want used in the expanded form defined in a Clojurescript file.
It might be confusing that Clojurescript macros run in Clojure and thus see different set of available symbols than the expanded code will.
But even so, I still don't understand why this doesn't work :-
(defn foo []
(println "foo"))
(defmacro call-foo "call foo"
[]
`(juxt.iota/foo))
(ns juxt.iota)
(defn foo []
(println "foo"))
(defmacro call-foo "call foo"
[]
`(juxt.iota/foo))
ah, yes, they're in the same file
this is a .cljc file, so I need to move the macro to a .clj file
ah, this is now making a little more sense
.cljc has confused me
Yeah, you can't have macros in Clojurescript source files. I suppose emitting the macro with reader conditional for :clj
might work, but I didn't try it.
right, that now makes sense, thanks guys
No problemo, first time I encountered that phase difference I was confused as well. And by the fact that you can't use println
during macroexpansion due to rebound *out*
oh, I didn't know that - thanks for the warning!
You can use this instead - https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/util.cljc#L179-L184
really appreciate your help on this, I was banging my head against a wall and my head was beginning to hurt
Yeah, I can imagine. It's unfortunately a Clojurescript limitation that you have to be aware of.
debug-prn - that's a good one to know
I just about grokked the clj for macros, cljs for clojurescript, but then .cljc came along and confused me!
I guess macro writers need to be punished occasionally and today was my turn
exactly
I have upset the macro gods, I'm going off to make a sacrificial offering...
thanks again for your help @jaen
I took a stab at “modernizing” the Differences fro Clojure wiki page to accurately accommodate some of the newer notions we now have with the existence of bootstrapped ClojureScript: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure/_compare/3dbb64badb7cd1313f6507505c26ef20e73e52c7...001b020761f33a75d5e6e82b13100c2c1d616306