This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-28
Channels
- # admin-announcements (28)
- # beginners (30)
- # boot (6)
- # cljs-dev (48)
- # clojure (72)
- # clojure-android (8)
- # clojure-australia (1)
- # clojure-italy (9)
- # clojure-japan (12)
- # clojure-russia (21)
- # clojure-sg (1)
- # clojurescript (109)
- # core-async (11)
- # core-logic (17)
- # cursive (33)
- # datascript (1)
- # datomic (30)
- # dunaj (4)
- # editors (38)
- # events (1)
- # ldnclj (17)
- # off-topic (156)
- # om (2)
- # overtone (1)
- # re-frame (2)
- # reagent (63)
@dnolen: Other than with-bindings and the var, do you think the approach in cljs-1367 is correct? Wrapping implementation calls in namespaces where the api call takes in opts argument
@juhoteperi: yes, but I actually want to do another thing
which is for all those functions to to have an additional arity that takes the compiler state
it won’t break previous users if it’s an additional arity, where the state is the first argument
Sounds good
@juhoteperi: other than that yes that’s the right idea
I think this additional state argument is probably best solved in another ticket and patch?
@juhoteperi: could do, but just simpler to just fix it all in one go.
Instead of with-bindings I would use macro or function:
(defmacro with-api-opts [opts & [body]]
`(binding [ana/*cljs-warning-handlers* (:warning-handlers ~opts ana/*cljs-warning-handlers*)]
~@body))
(defn with-api-opts [opts f]
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
(f)))
This would also make it easy to extend it later if other "api-opts" are added
@juhoteperi: do not with anything with-x
thing at all
@dnolen @juhoteperi I am all for the "pass the state as an argument". This is what I ended up doing to hide the analyzer from the rest of the code in a doc generator: https://github.com/funcool/codeina/blob/master/src/codeina/reader/clojurescript.clj#L76
build and watch btw. already take the compiler-env as argument, but it's not the first argument
@juhoteperi: can’t do anything about those.
Would it be okay to make cljs.analyzer/default-warning-handler
public and expose it in api? If :warning-handlers
overwrites the warnings handlers, I need some way to access the default handler
Compiler-env is necessary for cljs.analyze/analyze
, right? So it makes sense if it throws error if it isn't passed compiler-env or dynamic var isn't set
@juhoteperi: if analyze
didn’t throw before it’s not going to throw now
@juhoteperi: there should be a function to return the default warning handler sure in the api
ns
Okay. I'll attach a patch to Jira for comments (it still needs fix for analyze
)
@juhoteperi: thanks!
@juhoteperi: patch looks good, I think we probably want to put warning handlers into the compiler state along with the other queryable things, but we can do that later.
@dnolen: Did you check the note about analyze
?
@juhoteperi: note where? in the patch?
@dnolen: jira comment
@juhoteperi: ah no, we should probably dupe the code and have two code paths, one for state nil and not nil
@dnolen: Dupe which part of the code? with-compiler-env or the call to implementation from every api call?
something like:
(defn analyze* [...] (binding [...] ...))
(defn analyze ([...] (analyze* ) ([state ...] (analyze* ...)
Or I could just copy the option binding to the other arity
@juhoteperi: I suggesting something way less clever
I noticed another thing in analyzer.api
ns, the calls which directly access compiler-env will throw an error when trying to deref nil
@juhoteperi: thanks much for working on this btw, a big improvement