This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-26
Channels
- # arachne (4)
- # beginners (70)
- # bigdata (1)
- # boot (373)
- # braid-chat (3)
- # cider (4)
- # cljs-dev (10)
- # cljsjs (6)
- # cljsrn (27)
- # clojars (11)
- # clojure (114)
- # clojure-austria (1)
- # clojure-czech (2)
- # clojure-dusseldorf (2)
- # clojure-greece (7)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-russia (15)
- # clojure-serbia (11)
- # clojure-spec (92)
- # clojure-uk (5)
- # clojurescript (183)
- # component (9)
- # cursive (28)
- # datomic (36)
- # editors (4)
- # emacs (1)
- # garden (11)
- # hoplon (155)
- # lein-figwheel (7)
- # mount (47)
- # om (97)
- # onyx (25)
- # proton (3)
- # rdf (3)
- # re-frame (80)
- # reagent (9)
- # ring-swagger (9)
- # spacemacs (1)
- # untangled (145)
- # vim (2)
IMO it is great that there is a new option to run closure without JVM, but I’m not aware of any game where this could be considered a game changer 🙂 are you aware of any? e.g do you know any bootstrapped app where this would unlock some fundamental new powers with advanced optimizations on client-side?
is there a standard way to check for logical truthiness, aside from using an if statement?
i can just define truthy? myself, just wanted to see if i’m missing something super obvious
nah, my function under test returns logical truthy values, like 1
, etc, instead of always returning true
i was able to easily solve the problem by just doing (def truthy? [x] (if x true false))
and vice versa for falsy?
; perhaps the fact that i had to define these myself is that an indicator that i’m doing something wrong/unusual
i guess i’ll stick with my truthy/falsy functions for now, since (is truthy? (function-under-test))
is slightly less verbose than (is true? (boolean (function-under-test)))
, but in future non-test situations when i have this problem, i’ll reach for boolean
@darwin you could run a dev environment entirely in the browser?
could be a good getting started environment
why not just (is (function-under-test))
?
identity
is the truthy function
i can’t get my atom to change to a new default state even though i’m using def
and have restarted figwheel 11 times? any idea?
i’m very silly and had this in my code:
(on-show [this]
(reset! state {:text-x 20 :text-y 30}))
😳 nevermindHey all, I am trying to play around with making externs for adapter.js (https://github.com/webrtc/adapter) so I can try some things with webrtc. It seems to be much harder than I expected because adapter.js is a polyfill. Normal looking externs don't appear work. My current thinking is something along the lines of this:
navigator = {
"getUserMedia": function () {},
"mediaDevices": function () {}
}
navigator.prototype.mediaDevices = {
"getUserMedia": function () {}
}
navigator.mediaDevices.prototype.getUserMedia = {
"then": function () {},
"catch": function () {}
}
to support https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia and https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMediaUnfortunetly this causes the closure compiler to point out that navigator
is contant
Also should note it appears the externs are built into the compiler (https://github.com/google/closure-compiler/blob/a98aa7798031d9484ffcc408a457126790d3e3a3/externs/browser/w3c_rtc.js, https://github.com/google/closure-compiler/blob/a0b884082dbef77d2d336705b32d99e0a930dc54/externs/browser/window.js) but including adapter appears to cause them to get shadowed and overwritten
I have a question about foreign-libs if anyone has a moment
I have a dependency that is in the form of http://<remote url> but when I compile it looks in my local file system and a I get a file not found exception, I am running this on ubuntu
hey guys… anyone using doo
as test runner? I can’t get it to work. just adding the plugin dependency (without any other changes) already breaks things. Starting figwheel seems fine, but then it complains about js/testable.js
which I assume is part of default configuration of doo. Also when I start figwheel it throws a strange message:
---- Could not Analyze ----
java.lang.IllegalStateException: assert-args already refers to: #'cljs.support/assert-args in namespace: cljs.core, compiling:(cljs/core.clj:139:1)
---- Analysis Error ----
Any clue what that may be?@ag: doo’s working fine for me, here’s my setup: https://github.com/jrheard/voke/blob/master/project.clj
excluding clojurescript from lein-doo fixed the compile-time warning, but still whenever I go to localhost, it’s trying to get js/testable.js
I don’t have that thing listed anywhere.
i’m heading to bed, but https://github.com/bensu/doo/search?utf8=%E2%9C%93&q=testable.js hopefully has the answer somewhere
(does your build map have a :compiler map whose options specify an :output-to string? might be relevant, but i don’t know the answer any more than you do - glgl!)
Hello. What is the current alternative to shoreleave? Seems it hasn't been updated in a while
Does someone know if the 2nd edition of Clojurescript up and running by @stuartsierra and Luke VanderHart was delayed publication, if not, where is it available (can't find it on O'Rilley online shop).
@jrheard: Only a week or two ago, I also implemented the truthy?
fn, and I had the same feeling - "why isn't this in core?" (To recap: (defn truthy? [x] (if x true false))
)
I mean, there is true?
and false?
, so leaving truthy?
out seems like an oversight.
It's quick enough to implement yourself, but truthyness is a basic building block of the language, so it seems like it should be in clj/cljs core.
@reefersleep you are reinventing wheels: https://github.com/clojure/clojurescript/blob/71c93368aedd49ed3ab5156c78a379e14e275ce8/src/main/cljs/cljs/core.cljs#L2094
I would say: not 🙂
That's better!
that’s what (if x …)
gets compiled to
I think your version of truthy?
is not optimal, because it will call cljs.core/truth_ instead
@darwin exactly
truthy?
would imply 2 fn calls
I was nowhere near optimization territory, it was more of an exploration
I think that I would still prefer for the fn to be called truthy?
rather than boolean
, though, but that's because I'm caught up in the true?
and false?
naming scheme
It might be that boolean
slots in neatly with other naming conventions in core.
Again, the "truthy" aspect is avoided
We speak of truthyness when talking about aspects of Clojure, but avoid it in the fn names. Or, at least in this one case. 🙂
But good to know, @hlolli!
I just find it a bit weird, since after reading about truthyness in a Clojure guide, it would be very natural for anyone to be wanting to ask: is this value truthy?
Especially since you can ask the same for false?
and true?
, and since using these two fns as a newbie might trip you up regarding the truthyness of your value (it did for me, anyway!)
Yes, sometime I manually find myself returning true and false. But by far most of the time when
does all I want. Its just a question of habits probably coming from other languages like Ruby I would guess.
I don’t get it, truthiness is implicit question, instead of (if (truthy? x) ...) you simply say (if x ...)
Yes @darwin, but sometimes you might want to use it in a different way, say (map truthy? [1 nil false "five"])
In which case, I guess you'd use some?
. Which is fine!
Avoiding truthyness again (and why? I have never heard "identity" mentioned in newbie guides, but "truthiness" loads of times)
There is nothing wrong with those fns 🙂 I just find the naming, or at least the lack of explicit truthy
-ness in the naming, a bit counter-intuitive
ok, I get your point now, have nothing against another function for it, for code to read better
You can rename some? to be truthy? when you require cljs, but this would cause everyone looking at your code to become very confused.
@hlolli: Yes, and I wouldn't want that. I would prefer Clojure itself to be that tad more newbie-friendly and have the more appropriate name in core. If indeed it is more appropriate - I can't say. I was just confused, personally.
Good to have that cleared up.
Where does the identity
name come from? I think I've picked it up in some general functional concept vocabulary.
(I'm not going to march with banners in order to change cljs/clj core, btw, just pondering stuff out loud here : )
@darwin: Cheers 🙂 Thought it might be something like that.
btw. I have another example where I don’t write idiomatic code to be more readable, I’m using (not (empty? coll))
instead of (seq coll)
, it just reads better IMO
I tend to agree with that, although I've been trying to alter my perception by forcing myself to use (seq coll)
so that reading code with that in it doesn't cause me cognitive strain 🙂
After this discussion truthy? would not be really bad idea. But I think clj.core community would be those you would need to convince.
@hlolli: Yeah, and I'm really not up for that. 😄
In general, I'm hoping for the implementation of specs in core fns to give Clojure and ClojureScript a huge boost in newbie friendliness (and general developer friendliness!)
It's far from the easiest language to get started with.
clojurescript is not newb friendly at all, that needs to be improved. One newb trap is not to learn clojure first, another roadblock is of course the tooling madness one needs to understand. What do you think is the most diffucult part of understanding cljs @reefersleep ?
That's a tough question, @hlolli... Can't name one thing off-hand.
But the confusing error messages and stack traces are definitely a candidate.
I’m working on my first app, and using the Luminus template. For some reason my compiled app javascript has stopped loading, and I can’t figure out why.
In the target/cljsbuild/public/js/out/myproject directory, app.js is present and is exactly what I’d expect
And this just seemed to happen on it’s own (I know, obviously it didn’t, but it seems that way) — I wasn’t mucking with project.clj when it began.
Anyone encountered a config issue like this before? I’m four hours into it and getting irritated with my own thickness
Am I correct in understanding that I cannot use cljs.spec’s fspec for much of anything without requiring clojure.test.check.generators
too ? (Everytime I pass in a spec which, at some level, uses fspec to s/conform
I get a stacktrace complaining about clojure.test.check.generators
not being required
When trying to check whether a function conforms, the way that's done is by invoking it with generated args
Which requires the arg generators
this is specifically for fdefs with fspec (higher-order fns)
sorry, I’m thinking of instrument conformance, not just s/conform
but maybe it’s the same thing
something like (s/conform (s/fspec :args (s/cat :x int?)) #(println "hi" %))
will generate int args for :x and invoke the function
so will fail if test.check is not available for generator support
there is no other way to verify that a passed function conforms to the spec you’ve specified using fspec
OK, so in essence if I wanted a more racket-like way to check my functions I’d have to use spec checks inside :pre & :post assertions on my functions
yeah, or s/assert
I assume s/assert came over to cljs :)
It’s there, I saw it earlier today, I’ll just have to enable assertions to use it, but that’s a minor problem 🙂
Well, maybe it was my boot project then, but (s/assert) happily powered through some tests that should’ve spat out metres worth of stacktraces 🙂 I’ll just be sure to enable asserts
hm - so part of my cljs app uses a couple of vanilla JS files, and it gets access to them via a couple of <script> tags in my html page, like so: https://github.com/jrheard/voke/blob/master/resources/public/index.html#L10-L11 but now i’d like to test this part of my cljs app (i’m using cljs.test and doo) what’s the recommended way of giving my app access to these vanilla JS files at test time, so i can test code that makes calls like (js/Collision.foo), etc?
one js file depends on the other directly, so i was worried that that would be an issue, but adding both to foreign-libs and requiring both of their namespaces seems to do exactly what i want
Gonna repost a question I had last night for visibility: https://clojurians.slack.com/archives/clojurescript/p1474857935004614
MediaDevices.prototype.getUserMedia = function(constraints) {}
from the compiler externs would be analogous to
navigator.mediaDevices = {
"getUserMedia": function () {}
}
@dimovich this isn’t a ClojureScript question really - it’s just how browsers & JavaScript work
So cljs.spec/assert isn’t working out for me, REPL example: http://paste.lisp.org/display/327173 Note. I’ve also tried calling it from within functions I know are being executed (and added some print statements to verify the changes being picked up) - s/assert is ignored while regular asserts aren’t, any clues ?
Is it posible to mark all the symbols in a namespace with ^:export
(without doing it literally)?
@novakboskov not possible
guys, I still can’t figure out my problem with lein-doo. would you help me to figure this one out? https://github.com/bensu/doo/issues/117. Thanks a lot!
you mean like this?
:output-to “resources/public/js/tests/out/test.js”
:output-dir “resources/public/js/tests/out”
@ag it’s a bit difficult to debug your problem since that repo doesn’t make any sense wrt. to the project.clj
oh right.. I took some parts from other project, but why doo
even bother doing anything when I am not doing (in figwheel) anything related to test
profile?
I don’t know what you’re talking about since I didn’t actually try that project given the above problems
yeah, it’s not very related to clojurescript (I guess) just couldn’t find better channel to ask for help
@ag: Is the problem you're dealing with related to doo, figwheel, or clojure-future-spec? Here are a couple of ideas to reduce the problem space and make it easier for other people to help - Reduce your dependencies to a few sets of minimum tests - maybe one with figwheel + doo, one with doo + clojure-future-spec, etc. - If there's a problem with clojure-future-spec, try the same minimal dependencies test but with clojure 1.9.0 alpha 13 instead - does it work with normal spec? I've found that this is usually my first troubleshooting step, and it often exposes some interaction that I didn't consider or shows me an error that was otherwise very difficult to find. At the very least it should point you in a direction to investigate further.
@shaun-mahood right, I wil try to disable some dependencies… it even maybe problem with ring…