This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-03
Channels
- # admin-announcements (6)
- # announcements (1)
- # beginners (17)
- # boot (69)
- # bristol-clojurians (1)
- # cider (7)
- # cljs-dev (115)
- # clojure (76)
- # clojure-russia (12)
- # clojure-sg (2)
- # clojurescript (152)
- # core-async (2)
- # core-logic (7)
- # cursive (18)
- # datascript (4)
- # datomic (2)
- # hoplon (12)
- # ldnclj (26)
- # off-topic (1)
- # re-frame (48)
- # reagent (6)
@dnolen: the macro question in #C03S1L9DN originated from the stuff above. with @bensu’s help I figured out that using a
` wasn’t the right thing here:
(defmacro define
[sym default]
(let [defname (-> (str *ns* "." (name (symbol sym)))
(clojure.string/replace "-" "_"))
goog-define (str "/** @define {boolean} */"
"goog.define('" defname "', " default")")]
(list 'do
(list 'declare (symbol sym))
(list 'js* goog-define))))
@martinklepsch: re, CLJS-1389 before spending any more time on a particular solution I would first explore why just emitting CLOSURE_DEFINES
under :none
is not satisfactory
@martinklepsch: adding any new api should always be considered as a last resort
@dnolen: agree.
@dnolen: the problem is that overriding defines with CLOSURE_DEFINES
only works for defines done with goog.define
. So far so good. Now they still need the @define
annotation. Plus when using goog.define
you don’t actually declare a var causing undeclared var warnings down the line.
@martinklepsch: how did you come to this conclusion
ticket has a link
http://google.github.io/closure-library/api/source/closure/goog/base.js.src.html#l147
based on all threads about this issue previously what you are saying is simply not true
I see that there’s a part missing. let me check.
@martinklepsch: I’ve commented on the ticket what I think should be done.
@dnolen: I think I did exactly the change you suggest and ran into problems but let me check again first
@martinklepsch: again all threads I have ever read say what I suggested work
if you can prove that it can’t the ticket needs to include documentation demonstrating this
Will do.
Thanks!
@martinklepsch: looks like someone forgot to elevate your privileges in JIRA
great. thank you
@martinklepsch: rationale is much better now, in general tickets should proceed with that before proceeding further.
@martinklepsch: so it seems like we’ll want the define
helper macro + support to construct CLOSURE_DEFINES from the compiler options under :none
yeah? The macro was just an experiment really. You think it’s the best option?
The CLOSURE_defines
stuff is trivial really.
yeah, wasn’t thinking about function but rather having something like (def ^:goog-define thing true)
or so. That said I have no clue if that would be a good or terrible idea.
@martinklepsch: that’s a more invasive change not less
@dnolen: ok. will try to smoothen that macro then.
@dnolen: is there some fn that converts a cljs my.thing/sym?
to my.thing.sym_
?
cool. Thanks
@dnolen: The right place to add this would be core.cljc
is that correct? What’s the “flow” of making changes in there? evaluating the ns form in a repl throws a bunch of stuff at me.
@martinklepsch: never had any issues loading that file in a REPL
ok, must be something with inf-clojure then
@dnolen: can you point me to a macro that is similar to the define
one? Don’t quite understand what to scope in :cljs
conditionals and what not
@martinklepsch: don’t worry about :cljs
for now
ah, k. This is what I have right now: https://gist.github.com/martinklepsch/2e4a20e98ead0ed6953d
but it gives be Unable to resolve symbol: js* in this context,
— mostly took inspiration from the other macros and they seem to do it the same way?
@martinklepsch: that macro seems unnecessarily complicated to me
tbh, my macro skills are non-existent — very happy to be educated
@martinklepsch: the less you do with js*
the better
oh, right!
yeah makes sense.
@martinklepsch: as far js*
not working, see the arithmetic macros like +
@dnolen: my problems with js*
not working weren’t caused by the macro stuff but rather by things like calling str
instead of core/str
.
this also causes exceptions with js*
being unresovable which confused me
I have something that works now: https://gist.github.com/martinklepsch/2e4a20e98ead0ed6953d — feedback appreciated
@martinklepsch: looking good
@dnolen: Cool!
cool. will upload something to JIRA in a bit then
@dnolen: is main injected during :whitespace
?
because in theory CLOSURE_DEFINES
would need to be present for whitespace as well
at least as far as I understood — :whitespace
is still uncompiled in Closure lingo right?
@martinklepsch: I believe so but would need to verify
yeah agree, just making sure things are clear
I am hoping to contribute some effort to cljs development. what is the best way to get oriented as a newb?
@mikepence: make sure you have sent in your CA. Then scan through the tickets and JIRA and pick something that tickles your fancy
@dnolen: can’t get it to work in node. Does the node_bootstrap.js
somehow create a new context where the previously set vars aren’t available anymore?
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/bootstrap_node.js#L48
@martinklepsch: remember Node.js has modules
you need to be careful how you create CLOSURE_DEFINES so everything can actually read it
so var goog.global.CLOSURE_DEFINES
vs. just var CLOSURE_DEFINES
basically?
ah right yeah.
Dunno much about node tbh
@dnolen: thanks, that helped
@dnolen: I added a patch. Can add a second one with the sample thing if wanted.
@martinklepsch: thanks!
@dnolen: has been fun! thanks for all your guidance
@martinklepsch: patch looks OK, just needs to be rebased to master.
@dnolen: done. not sure if how I can remove the old patch
@martinklepsch: I tweaked the docstring, we actually munge :closure-defines
for the user in cljs.closure/add-implicit-options
if some tool is not passing build options through cljs.closure/add-implicit-options
that’s a bug
ah, great. I somehow assumed there is no processing being done there.
should have checked the claim that it doesn’t work
@martinklepsch: thanks for the patch, nice enhancement
Happy to get it in. Parameterized builds without custom macros and env vars across all optimization modes is really handy
it sure is, low hanging fruit like this is definitely some of the most impactful contribution
@martinklepsch: going to rename define
to goog-define
to make it more clear. cljs.core/define
is just a bit too weird semantically
yeah, I was considering suggesting that but you seemed fine with it so 👍
define indeeed seems weird given that def
is basically saying the same
anyways, go for it.