Fork me on GitHub
#clojurescript
<
2015-06-28
>
dnolen00:06:33

@meow: I suspect you think js is more sophisticated than it actually is. It doesn't really do anything.

shaunlebron02:06:12

@meow: that’s all the info that comes out of a js/ symbol analysis, and then that info is emitted here and passes through the munge function: https://github.com/clojure/clojurescript/blob/a3dc10bc333aa4ad0178c3e23dcaba87bbaea505/src/main/clojure/cljs/compiler.cljc#L303

shaunlebron02:06:34

munge is a little hard to follow, it’s changed since I last looked at it, but I’m sure it just strips the js/ out of the symbol and emits it

shaunlebron02:06:30

@jellea: I played with core.async animations using a go-loop that listened to a timeout channel

shaunlebron02:06:17

and also played with requestAnimFrame that wrote dt values to a mult channel that other go-loops could listen to

shaunlebron02:06:46

but I actually got myself into some trouble using the latter with channel back-pressure I think, the requestAnimFrame was writing too many values to the channel. I never figured that out

shaunlebron02:06:45

I would just play with the timeout channel:

(go-loop []
  (<! (timeout (/ 1 60))
  (swap! state update-in [:x] inc) )

shaunlebron02:06:59

some example code for the requestAnimFrame channel thing, with the aforementioned problems on slower machines: https://github.com/shaunlebron/solar-system-of-js/blob/master/src/solar_system_of_js/animate.cljs

meow03:06:19

@dnolen: nah, I was just curious how it was hooked up, that's all.

meow03:06:23

@shaunlebron: awesome! thank you for those links. I had fun looking through a bunch of the cljs source code, just couldn't find where that particular trick took place. Thanks. simple_smile

jellea09:06:54

@shaunlebron: Think I’ll go for the go-loop + timeout then! Thank you!

sander11:06:09

jellea: don’t forget to (recur) within that loop, i’ve been surprised often there

dnolen11:06:19

@meow: ah I misunderstood. You were digging into the compiler. cljs.analyzer/resolve-var, notice it just skips everything.

meow12:06:52

@dnolen: yes, I saw that. Also this little trick

(defn implicit-import? [env prefix suffix]
  (contains? '#{goog goog.object goog.string goog.array Math} prefix))

dnolen12:06:31

yep, that's how it works simple_smile

meow12:06:21

I'm learnin' simple_smile

meow12:06:51

Another ns trick for Math CLJS-1178: Compiler does not know Math ns is not not-native

dnolen13:06:38

optimization thing around invocation - but heading into the weeds now IMO simple_smile Unless of course that's your kind of thing.

dnolen13:06:52

@meow: see the :invoke case of emit* in cljs.compiler. It's a pretty gnarly piece of code but a big reason ClojureScript code is hot-swappable under dev but fast under production.

meow13:06:43

@dnolen: not sure if I'm going to have time to track this down today but does this smell bad to you at all: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L499

meow13:06:18

I'm wondering why goog.object and goog.array are not in the set

meow13:06:01

(when (and (nil? (get '#{cljs.core goog Math goog.string} ns-sym))

dnolen13:06:20

@meow: just a bug, I would file a minor JIRA issue.

dnolen13:06:40

@meow: even better attach your first patch to it. Typical low hanging fruit.

meow13:06:56

would something like (when (and (not (implicit-import? ns-sym)) make sense?

meow13:06:38

well, I'd have to pass the right args

meow13:06:45

@dnolen: I'll work on a patch - probably won't see it until Tues or Wed as I've got things going on.

shaunlebron15:06:37

@sander: good catch with the recur, always forget that

jamiei18:06:20

Does anyone know how you can access the destructured route params from within an Om component if you're using Secretary for routing?