Clojurians
#cljs-dev
<
2016-09-18
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

shaun-mahood04:09:44

@dnolen: Your talk from ClojuTRE was fantastic! 2 questions from it: - For individual improvements or issues I know that Jira has a lot of info, is there anywhere that has a sort of long term or wider view on the future possibilities of ClojureScript? Sort of the next 5 years in text form or a long term desired roadmap. The no externs and DCE on React in particular are pretty awesome possibilities that I've never thought of before. - Based on your experience and seeing the amount of work and time for ClojureScript to get where it is today, do you have any thoughts on what it would take to target another platform with the same approach (such as Swift or Erlang)? This question is way more related to curiosity than any need to do such a thing, but seeing the amount of work that goes into ClojureCLR for such little reach or usage makes me wonder if the ClojureScript path would make something like that more possible - I really would love to be able to use Clojure everywhere for everything and that's still a bit out of reach.

darwin18:09:36

having issues with deps order under :whitespace mode, due to security restriction of chrome extensions, for content scripts I have to build one static js file, that is why I’m using :whitespace mode during development. Looks like under :whitespace the the sources of deps are concatenated. But this order might not sort deps in the the proper order where goog.provides go before goog.require calls. I ended up with a file where goog.require(“goog.labs.userAgent.util”) is called prior goog.provide(“goog.labs.userAgent.util”) call. Is this a known issue? Quick skimming through JIRA didn’t really give me anything like that.

anmonteiro18:09:44

@darwin FWIW I also don’t recall having seen that in JIRA. Can you repro using latest CLJS?

darwin18:09:58

yes, using the latest, I will try to shrink it for more palatable repo case, definitely hit the problem by relying on some goog-related namespaces

anmonteiro18:09:40

@darwin can you repro it using advanced compilation?

darwin18:09:09

testing it with advanced build right now, but I guess whole goog.require thing will be stripped there

darwin18:09:23

I could maybe give you cljs_deps from :none build, where we will probably see the order :whitespace build

darwin18:09:40

I assume :whitespace simply emits sources in the order it builds cljs_deps table

darwin18:09:53

and that might not be correct

richiardiandrea18:09:32

I need a confirmation for a behavior, I noticed that in replumb:

(def a 0)
(defmacro m [] `(println "hey"))
(keys (:defs (get-in @replumb.repl.st [:cljs.analyzer/namespaces 'cljs.user]))) ;;=> (a m)

richiardiandrea18:09:15

is it expected? because I remember I had to use the :macros key to inspect macros' ast before

anmonteiro18:09:28

@richiardiandrea it is if you define a macro at the REPL

anmonteiro18:09:45

because it’s defined in the same compilation stage

richiardiandrea18:09:34

ok, so not if I return code from load-fn right? If so, I have a failing test in replumb that might show a bug (maybe?)

darwin18:09:54

@anmonteiro FYI, under :advanced build all works as expected, there are no goog.require or goog.provide calls (using pseudonames, so I would spot it even after renaming)

anmonteiro18:09:37

@darwin I’ve also spotted subtle issues in :simple optimizations with cljs.pprint

anmonteiro18:09:55

it seems those compilation modes haven’t been given the same love as :advanced

darwin18:09:04

I’m going to investigate the cljs_deps.js file under :none mode now

darwin18:09:16

I think it will give us clue about the order

anmonteiro18:09:10

@richiardiandrea if we’re talking about the same thing, you can also reproduce that behavior in JVM ClojureScript

richiardiandrea18:09:11

to recap, if we are talking about stages: if the load-fn actually returns a defmacro right there, I should see the macro symbol in :defs whereas if it uses require-macros it should appear under :macros, am I right?

darwin18:09:43

I think quick solution would be to have post-process step for :whitespace/:simple modes and move all goog.provide calls at the beginning of the file, that would solve it

anmonteiro18:09:01

@richiardiandrea the following is in ./script/noderepljs

cljs.user=> (defmacro m [] `(println "key"))
true
cljs.user=> m
#object[cljs$user$m "function cljs$user$m(_AMPERSAND_form,_AMPERSAND_env){
return cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,new cljs.core.Symbol("cljs.core","println","cljs.core/println",-331834442,null)),cljs.core._conj.call(null,cljs.core.List.EMPTY,"key"))));
}"]
cljs.user=> (m nil nil)
(cljs.core/println "key")
cljs.user=> 

anmonteiro18:09:38

I think what you’re saying above is correct, yes

anmonteiro18:09:24

the thing to note is that the macro should be defined in cljs.user$macros

richiardiandrea18:09:48

yes that part was clear, but replumb also tries to fetch things from the ast directly

darwin18:09:19

I have been using this :whitespace setup for a while without problems. Today I reconfigured it and started using cljs-devtools via :preloads. This is probably the reason, either it triggered the bug or the bug is only related to preloads.

richiardiandrea19:09:46

so a question (sorry, long) again for the new things, if I return:

(cb {:lang :clj
                             :file "fake-source/bar/core.cljs"
                             :source "(ns bar.core)
                                      (def foo 42)
                                      (def bar 42)
                                      (def baz 42)
                                      (defmacro unless [pred a b]
                                        `(if (not ~pred)
                                          ~a
                                          ~b))
                                      (defmacro abs [x]
                                        `(unless (neg? ~x)
                                          ~x
                                          (- ~x)))
                                      (defmacro sqrt [x]
                                        `(unless (neg? x)
                                          (Math/sqrt x)
                                          (throw
                                            (ex-info \"Real plz\" {}))))"})
and then:
(require '[bar.core :refer [foo bar]])
(require-macros '[bar.core :refer [abs sqrt]])
is this correct?
(keys (get-in <@U07E9BBBN> [:cljs.analyzer/namespaces requirer-ns :use-macros])) ;; => (sqrt abs bar foo)
I am asking because before I use to receive only (sqrt abs)...

richiardiandrea20:09:21

I have a test in replumb and it is the only one failing: https://travis-ci.org/Lambda-X/replumb/builds/160882208

richiardiandrea21:09:12

so I found the problem in the previous piece of code. By doing:

(require '[bar.core :refer [foo bar]])
(require-macros '[bar.core :refer [abs sqrt]])
and returning the same ns from the load function it looks like I am invoking code in the two different "stages" manually, and foo and bar are included in :use-macros together with abs and sqrt. Instead, with a normal:
(require '[bar.core :refer [foo bar] :require-macros [abs sqrt]])
The :use-macros key in the ast correctly contains only abs and sqrt

richiardiandrea21:09:32

mmm...still something weird going on...I'll try to figure it out