This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-09
Channels
- # adventofcode (1)
- # aleph (2)
- # beginners (28)
- # boot (26)
- # boot-dev (8)
- # cider (10)
- # clara (10)
- # cljs-dev (130)
- # cljs-experience (1)
- # cljsrn (12)
- # clojure (118)
- # clojure-austin (40)
- # clojure-boston (1)
- # clojure-chicago (1)
- # clojure-dusseldorf (1)
- # clojure-estonia (11)
- # clojure-france (1)
- # clojure-greece (3)
- # clojure-italy (19)
- # clojure-nl (1)
- # clojure-russia (1)
- # clojure-spec (19)
- # clojure-uk (34)
- # clojurescript (62)
- # core-logic (7)
- # cursive (11)
- # datomic (35)
- # emacs (15)
- # fulcro (264)
- # jobs (4)
- # leiningen (5)
- # midje (4)
- # off-topic (74)
- # onyx (27)
- # planck (14)
- # protorepl (4)
- # re-frame (37)
- # reagent (62)
- # rum (2)
- # shadow-cljs (171)
- # slack-help (5)
- # spacemacs (6)
- # specter (9)
@sonnyto, I assume the repl runs the compiled javascript in something like (function(){ *compiled cljs code* })();
@sonnyto My initial hunch is that, in the ClojureScript REPL, when you evaluate a form, it is not being done in the global JavaScript scope.
thanks! that works, however I do not understand that solution. what does binding js/eval to geval have that side affect?
You can get around this by, for example doing (let [geval js/eval] (geval "function abc(){}"))
@smith.adriane Yeah, I think you are right. Planck specifically doesn't do that in order to fix, for example https://github.com/mfikes/planck/issues/543 (see the bit at the very bottom of that bug thread)
interesting
As a consequence, in Planck:
cljs.user=> (js/eval "function abc(){return 1;}")
nil
cljs.user=> (js/abc)
1
seems like relying on that behavior is looking for trouble
geval and js/eval are equivalent right? there must be some side affect going on that i dont understand
Then 1. a. applies here http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.2
🙂 thanks for the response. i'll copy and paste this to the google group just in case someone else runs into same problem
as an aside, it seems doing something like
cljs.user> (def abc (js/eval "function(){}"))
(var cljs.user/abc)
cljs.user> abc
#object[Function "
function () {
}
"]
might be a good option rather than relying on names between the evaled js and the names cljs produces to matchWell, (js/eval "function(){}")
will compile to eval("function(){}")
, which is a direct call to eval
. The issue is that you don't have much control over the scope that this call is made within, and you may not be able to guarantee that you are running in an ECMAScript 5 VM, so there is probably no real good solution.
i’m not exactly sure what the use case, but the main difference is that the name no longer matters (ie. the variable name abc
is on the outside of the eval rather than within the eval)
and you’re no longer depending on how the code within the eval is scoped
and then you don’t have to know the ecmascript 5 vm rules
Hello,
I’m trying to make a client side cljs app to discover clj specs from the community. I’d like to be able to get spec from a gist or a textarea and provide a way to generate sample datas from the spec.
Looking at Lumo code, I think I have to use cljs/eval-str
which I successfully did to eval some trivial code and use it from the rest of the app.
I’m now struggling to eval some specs as I can’t figure how to require
cljs.spec.alpha
. Even looking at the load fn from lumo.repl
https://github.com/anmonteiro/lumo/blob/703e6bebc15624b1dd2306f4b1be4bafcce47507/src/cljs/snapshot/lumo/repl.cljs#L1137 I don’t understand what should I do.
I think I need to look at load-bundled
but I’m not sure because even when I do (cb {:source "" :lang :js)
I have an error :`cljs.spec.alpha.def is not a function`. I would assume that cljs spec is already there (bundled) because I have it as a dependency but that’s where I’m lost.
Could someone point me to the right direction if any ?
Thanks !
Hi 👋 . What input validation library would you recommend? Tried struct (http://funcool.github.io/struct/latest/) but it didn't support nested fields and haven't been updated in 2 years so I thought there might be something better
probably spec is now the default way to handle those kind of things
If validating input forms or similar, then you can use spec + https://github.com/alexanderkiel/phrase to generate the validation messages.
@jvuillermet I'd take a look at KLIPSE, which has a mechanism for loading code from a gist
hmm should this work in CLJS without anything special? (edn/read-string "#inst \"2017-10-12T13:00:00.000-00:00\"")
I’m confused why I would use the nominal clojurescript compiler vs. lumo vs. shadow-cljs
the repos don’t explain why I would use them, just that they can build clojurescript code as well
shadow-cljs is a full build tool, it also provides hot code reloading and more dev stuff
How come, Cljs cannot infer externs with code like this:
(def expo (js/require "expo"))
(expo.Audio.setIsEnabledAsync true)
Can I somehow do anything code-wise, instead of adding each call to expo.something
to externs.js
manually?
@grav did you try ^js
type hint on expo
? (also this is probably a defect and should open an issue about it)
I’m trying to figure out what to standardize on for my team and I’m having trouble finding out what features these different compilers/build tools have and what their value propositions are
I’m not aware of any actual comparisons. I can’t do one myself since I never used figwheel 😛
@lilactown lumo is bootstrapped so if you need/want to avoid JVM for some reason (less users but it’s a growing use case)
ClojureScript compiler is at the bottom of everyone’s efforts, bootstrapped or whatever
@dnolen No, ^js
doesn’t seem to make a difference. I did at some point see a WARNING: target/expo/inferred_externs.js:53: WARNING - name expo is not defined in the externs
, but I cannot seem to reproduce it.
@thheller Does shadow-cljs provide HUD similar to Figwheel and Boot-reload (a view on the browser to display warnings and errors)?
@thheller Oh, I see it now, warnings are displayed but errors not
Emacs/vim are still major editors and those don't have as good (... or any) static analysis. Many people probably keep the console open for errors, but HUD allows me to focus on just browser + vim.