Clojurians
#cljs-dev
<
2016-10-13
>

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

ndrluis01:10:23

I’m looking the issue CLJS-1519 and I changed all the arity error messages to understand where is the exception is raised, but the message doesn’t change. I’m running the repl using the wiki example and running from script/noderepl. Maybe I’m looking on the wrong place and this exception are raised from google closure.

lauri03:10:54

@ndrluis I believe the exception is raised there: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/compiler.cljc#L824 Did you rebuild the compiler as described at https://github.com/clojure/clojurescript/wiki/Building-the-compiler before testing the modifications?

ndrluis12:10:35

@lauri yes

dnolen13:10:36

@ndrluis the fix is simple but it exists in an unusual place

dnolen13:10:57

you need to look at the cljs.core macros file around deftype etc. where we produce IFn implementations

dnolen13:10:56

deftype’s which implement IFn get call methods, the call implementation handles the dispatch to arity + the error report

dnolen13:10:10

I suspect the mistake is that deftype methods take 1 additional argument - the instance

dnolen13:10:19

there’s nothing wrong with any of this

dnolen13:10:24

just the reported argument count

ndrluis13:10:18

thx @lauri and @dnolen, I will try to look where @dnolen said

dnolen13:10:14

@ndrluis to elaborate a bit more we allow more things than just JS functions to be invokeable

dnolen13:10:25

JS functions are all invokeable via call

dnolen13:10:36

so ClojureScript types that are also invokeable implement it as well

viebel14:10:02

A question about boostraped-cljs: what is the trick that makes macros from cljs.core available?

viebel14:10:13

when executing eval-str?

anmonteiro14:10:47

@viebel sorry can you clarify?

viebel14:10:32

@anmonteiro for example: why can I call the when macro inside an expression?

viebel14:10:43

where is the code of the when macro stored?

viebel14:10:20

usually, macros are not available at run-time

viebel15:10:04

In my case (js/goog.require "cljs.core$macros”) does nothing

viebel15:10:22

cljs.core$macros is already loaded

viebel15:10:43

I have not set :dump-core false. Is it related

anmonteiro15:10:00

@viebel what’s your problem specifically?

anmonteiro15:10:20

:dump-core doesn’t have anything to do with macros AFAIK

viebel15:10:31

I’m trying to optimize the load clojure.spec inside KLIPSE

viebel15:10:44

Currently, I load everything from github

viebel15:10:57

It’s a waste since KLIPSE uses clojure.spec

viebel15:10:04

So everything is already there...

viebel15:10:06

except macros

anmonteiro15:10:08

are you getting undeclared var warnings?

anmonteiro15:10:23

is that the problem?

viebel15:10:44

The problem is that I can’t find what is the right thing to do

anmonteiro15:10:46

or rather, what macros aren’t there? clojure.spec’s?

viebel15:10:51

what should do my load-fn

viebel15:10:17

I tried to make it calls the callback with {:source “”}

viebel15:10:28

but then :refer fails

viebel15:10:41

so now, I’m returning the analysis cache

viebel15:10:49

but I’m having issues with macros

anmonteiro15:10:58

the macros namespaces don’t really get “bundled” when you build ClojureScript on the JVM

anmonteiro15:10:16

so if that’s the problem you’re having, you need to load those files because they won’t be in your bundle

viebel15:10:39

This is exactly what I’m trying to do

viebel15:10:12

I asked about cljs.core macros - because it seems that they are bundled during the build

viebel15:10:26

So I wanted to do the same trick with clojure.spec

viebel15:10:28

makes sense?

anmonteiro15:10:39

right, I’m not sure I can help you then

anmonteiro15:10:02

the core macros namespace might even be treated in a special manner by the analyzer

viebel15:10:04

I also tried to load the macro source files but then I am getting an infinite loop

anmonteiro15:10:04

I’m not sure

viebel15:10:14

not sure why

anmonteiro15:10:27

because every other namespace depends on it

viebel15:10:31

maybe your patch could help?

anmonteiro15:10:50

what files are you getting an infinite loop with?

viebel15:10:12

checking...

viebel15:10:31

There was an infinite loop with cljs.core$macros

viebel15:10:59

So I made my load-fn return “” for cljs.core and cljs.core$macros

anmonteiro15:10:30

@viebel right there are some namespaces that you can skip loading

viebel15:10:53

macros namespaces also?

viebel15:10:00

except cljs.core$macos?

viebel15:10:25

who built this list?

anmonteiro15:10:48

Mike Fikes, I think

anmonteiro15:10:38

but some of those are Planck-specific

anmonteiro15:10:20

@viebel I don’t know how you’re compiling KLIPSE, but your list might be even longer if you’re compiling with simple optimizations

viebel15:10:28

I’m doing :optimizations :simple

viebel15:10:37

as :advanced is not supported with bootstraped

anmonteiro15:10:49

so you might have a lot of stuff already “loaded” in your build

anmonteiro15:10:56

that you can simply skip loading

anmonteiro15:10:06

that should shave off a lot of time in some require calls

viebel15:10:16

I’m trying now

viebel16:10:04

@anmonteiro it starts to work

viebel16:10:14

I can require clojure.spec

viebel16:10:26

I’m having issues when calling s/def

viebel16:10:03

WARNING: Use of undeclared Var cljs.spec$macros/def-impl at line 4

viebel16:10:35

somehow def-imp is resolved to the macro ns instead of the non-macro one

anmonteiro16:10:09

@viebel which version of ClojureScript?

anmonteiro16:10:11

or rather, are you using a given ClojureScript version in KLIPSE and fetching namespaces from GitHub master?

viebel16:10:55

not fetching from github

viebel16:10:16

using latest release: 1.9.229

anmonteiro16:10:51

1.9.229 in both the KLIPSE build and the clojure.spec namespace?

viebel16:10:04

let me double check

viebel16:10:12

I was with 1.9.277 for clojure.spec

viebel16:10:24

moved to 1.9.229 and now it works

viebel16:10:31

Thanks a lot for your help

viebel16:10:51

I hope that soon my articles about clojure.spec will load much faster

anmonteiro16:10:46

@viebel yeah, that’s what I suspected

darwin17:10:15

just wondering if there is some other state outside cljs.env to be addressed to get reproducible builds, I have some tests checking cljs compiler output in different compilation modes: https://github.com/binaryage/cljs-oops/tree/master/test/transcripts/expected it works pretty well, the problem is when I decide to change order of the tests or filter some out, I get slightly different results, the generated code is still correct, but js-beautify will format/insert linebreaks to some other places for some reason I just ran directory diff for two builds which happen to be different, and it looks that gensym and similar do not reset when calling new compiler/build, this is probably causing flakiness of my tests, because build depends on state of the system left from previous builds

darwin18:10:51

ah, nevermind, found the problem, because gensym and similar are not reset for each new build, we may end up with generated identifiers of different length, e.g. my-sym10 vs. my-sym12345, and this affects linebreaks of cljs output, solution for me was to remove all linebreaks to normalize the output before processing it further

darwin18:10:09

that alone is not enough to get stable output, I also have to “reindex” all auto-gen and gensym’d symbols with stable indexing, but that I had to do anyways

maria20:10:39

Would it be ok for me to work on http://dev.clojure.org/jira/browse/CLJS-1820? Shouldn’t interfere with deraen’s work :wink: