This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-16
Channels
- # aws (6)
- # beginners (129)
- # calva (9)
- # cider (4)
- # cljs-dev (2)
- # clojure (41)
- # clojure-beijing (2)
- # clojure-dev (3)
- # clojure-spec (23)
- # clojure-uk (46)
- # clojurescript (38)
- # community-development (20)
- # core-async (4)
- # cursive (12)
- # data-science (7)
- # datascript (13)
- # datomic (15)
- # duct (11)
- # emacs (18)
- # figwheel-main (5)
- # fulcro (26)
- # off-topic (4)
- # pathom (28)
- # pedestal (3)
- # reagent (8)
- # reitit (6)
- # shadow-cljs (32)
- # specter (3)
hi, using the firebase lib from cljsjs (aset (js/firebase.auth) "languageCode" "fr")
expression does work when compiled with :advanced option.
https://github.com/firebase/firebase-js-sdk/blob/master/packages/firebase/externs/firebase-auth-externs.js firebase.auth.Auth.prototype.languageCode;
appears, which i suppose the firebase wrapper in cljsjs uses
Hi. How would one write (cljs.test/is (thrown-with-msg? CLJS-class #"foo" (throw (ex-info "foo" {}))))
- as in, what should take the place of CLJS-class?
@dominicm Yes, that worked - thanks!
There several online ones like https://htmltohiccup.herokuapp.com/ I guess there should also be a library that does it.
Anyone know why these two expressions would print different results?
cljs.user=> (let [state (cljs.js/empty-state)]
#_=> (cljs.js/eval state '(def x 1) {:eval cljs.js/js-eval} prn)
#_=> (cljs.js/eval state 'x {:eval cljs.js/js-eval} prn))
{:value 1}
{:value nil}
nil
cljs.user=> (let [state (cljs.js/empty-state)]
#_=> (cljs.js/eval state '(def x 1) {:eval cljs.js/js-eval, :context :expr} prn)
#_=> (cljs.js/eval state 'x {:eval cljs.js/js-eval, :context :expr} prn))
{:value 1}
{:value 1}
nil
The docs for cljs.js/eval
claim that :context :expr
is the default: http://cljs.github.io/api/cljs.js/eval
@zane assuming you are running things exactly like that the first time cljs.user.x = 1
will be set in JS
since you don't restart the runtime inbetween that value is still there the second time
@thheller The thing that is confusing me is why simply cljs.js/eval
uating x
right after (def x 1)
prints nil
if :context :expr
is not set.
@thheller Additionally, I don't believe defining things via cljs.js/eval
(self-hosted ClojureScript eval
) ever affects the environment of the caller. Do you have a different understanding?
@zane everything you eval is eval'd in your runtime (eg. the browser), nothing is isolated. empty-state
only affects the CLJS analyzer state, not the state of the runtime itself.
uhm yeah that maybe right. not actually sure if cljs.js/eval
does some async stuff. if it does it may just be async not having eval'd yet.
it may just be the :context :expr
thing alone since the code will just not emit anything to eval
@thheller Thanks for the help! Is there something I could read to understand what the analyzer state is/is for?
hehe me neither. always hurts my head thinking about it. analyzer data is used by cljs.analyzer
for code generation stuff. It keeps all data about defn
&co defined in your namespaces.
not actually sure in self-hosted but I guess it will keep some infos about macros in there as well yes
looks like the doc might be wrong? https://github.com/clojure/clojurescript/blob/r1.10.516/src/main/clojure/cljs/analyzer.cljc#L686
Nice! If you're interested, I'd check in with the devs over at #cljs-dev and get an opinion on whether it's a doc string error or a code error.
If you want to try changing the default to :expr
then you should probably make sure to run the self host tests to make sure everything still works.
Another strategy would be to let ana/empty-env
default still to :statement
and check for lack of :context
in eval*
's params and give it :expr
if so. And test against that.
But if it's a doc string thing, there looks to be a number of different fns that declare :expr
as the default in their doc strings, so they may be wrong too.
If nobody sees it this weekend, somebody should probably see it this week. Remember to sign the contributor agreement https://clojurescript.org/community/contributing if you want to end up sending in a patch.