Is it possible to use local library in Clojurescript like we can do in Clojure? Will deps like below work?
{:deps
{time-lib/time-lib {:local/root "../time-lib"}}}
From personal experience it does not seem to work. Just wanted to make sure its doable.
it should. because everything works on a classpath. should be no difference if its in a jar in ~/.m2/repository/... or ../time-lib
Got it working, the directory structure at the local library did not match the namespace. Thanks @dpsutton
glad to hear. simple tools mean that the bugs can't hide too much
https://2020.stateofjs.com/en-US/technologies/javascript-flavors/
As a person working with scientific data, I find that page absolutely meaningless and just very unpleasant to look at. Good only, perhaps, for a chitchat over some beers.
It seems like interest for clojurescript from the JS community is still dropping years after years
@vnctaing I don’t want to make excuses but such a comparison does not seem very fair; I have never used TypeScript but it seems to me that it is effectively a … superset of JavaScript? Basically you just need to learn a few things, and you can get going on top of JavaScript; sort of like what spec is to ClojureScript… ClojureScript is a whole new way of thinking compared to JavaScript
I always found this survey kind of weird in its results. I'm not sure who answers it, but I'm always kind of surprised by the data, like its almost... odd
Just saw this thread in the archive on Zulip and I went and looked at that infographic and it's really misleading because it isn't to scale. Usage has remained steady (3%), awareness has hardly changed, Interest dipped by 12% but Elm is down nearly 30% (and it looks like Reason is up but it's actually 11% down from when it was first noted). Satisfaction has dropped 8% but the graph makes it look like it has tanked... And Elm's usage and awareness are both actually up but satisfaction and interest seem to have tanked -- how can that be?
I knew something was up with it 😛
It's like a subway map 🙂
On the topic of satisfaction though, I can see a lot of JS devs not liking ClojureScript, its so different, so much to learn, and if you just find yourself having to work on some ClojureScript code base, and you're a front-end dev with a JS background, I can see being a little frustrated by this.
Especially mixed with the front-end world. Last time I did front-end, you're not really programming, you're configuring a framework to do what you want, and the most frustrating thing is not finding the documentation that tells you the knob that you need for the the thing to do what you want. Which I can imagine Cljs must have the least amount of resource for that.
If you don't know Clojure enough to quickly peek to the implementation of reagent, rum, etc. And see the intersection with React, to be able to map in your head the React documentation to what you're doing, I can imagine that being really painful.
Which is why I feel, with "satisfaction" survey, I wish it would have something that tells me: of those that are satisfied, just how much are they? Cause its telling if something has overall low satisfaction, but of those that are satisfied, they are all fully satisfied and just in absolute joy with it. Versus something that has a lot of people being satisfied, but no one is like really in love with it.
How do I get rid of this error message in self-hosted CLJS?
ClojureScript 1.10.597
cljs.user=> (defmacro ctx-fn [ctx-bind & body]
#_=> `(with-meta (fn [~ctx-bind]
#_=> ~@body)
#_=> {:sci.impl/op utils/evaluate}))
#'cljs.user/ctx-fn
cljs.user=> (ctx-fn ctx nil)
^
WARNING: Use of undeclared Var cljs.user/ctx at line 1
cljs.user=> (defmacro foo [x] `(fn [~x]))
#'cljs.user/foo
cljs.user=> (foo x)
^
WARNING: Use of undeclared Var cljs.user/x at line 1
(cljs.core/fn [nil])
:thinking_face:
can't define macros in CLJS like that. not sure about self hosted but the way above will just call it like a function
right
I did put a #?(:cljs (:require-macros [sci.impl.analyzer :refer [ctx-fn]]))
in my ns decl
not actually sure you can do this in the REPL
don't care about the REPL, I just wanted to get rid of the > WARNING: Use of undeclared Var cljs.user/ctx at line 1 warning in my code for self-hosted during load time
it looks to me like the macro is being called as a function rather than a macro but thats where my self-host knowledge ends 😉
yet it does work in self-hosted when called
I used macrovich to solve similar issues, but this time around it doesn't seem to work
ah well, I got rid of the macro. less macros, less problems
Found a subtlety of CLJS this AM that I wanted to run by y’all - ==
calls out to -equiv
, but it doesn’t seem to pick up on any NEW -equiv
implementations. maybe it is bound at compile time?
The var #'==
on the other hand does do the right thing when applied.
for example:
(deftype Wrapper [x]
IEquiv
(-equiv [_ that]
(-equiv x that)))
(let [x (Wrapper. 10)]
(== x 10) ;;=> false
(#'== x 10)) ;;=> true
@sritchie09 my guess would be that because of the 10
number a compiler optimization kicks in to use JS ===
. guess that doesn't account for custom -equiv
impls comparing to numbers
yup, exactly, which is what I was installing
Ratio
support, js/BigInt
for two clearcut cases
and for a slightly funkier one, an automatic differentiation implementation that needs to compare “dual numbers” to normal numbers using just the primal-part
, not the tangent-part
@thheller actually, if I throw a println in the -equiv
impl and call (== x x)
it looks like my custom -equiv
never gets called, even if no number is passed as an arg
well =
is equiv
isnt' ==
just a numerics things?
(defn ^boolean ==
"Returns non-nil if nums all have the equivalent
value, otherwise false. Behavior on non nums is
undefined."
([x] true)
([x y] (-equiv x y))
([x y & more]
(if (== x y)
(if (next more)
(recur y (first more) (next more))
(== y (first more)))
false)))
not according to its implementation
Behavior on non nums is undefined.
?oh 🙂
its probably a function with a macro inlining stuff
(core/defmacro ^::ana/numeric ==
([x] true)
([x y] (bool-expr (core/list 'js* "(~{} === ~{})" x y)))
([x y & more] `(and (== ~x ~y) (== ~y ~@more))))
as expected uses JS ===
directly
okay, got it
thanks for the help sleuthing!
another spot that seemed like it might beg a patch was compare
, which has this branch for numbers:
(number? x) (if (number? y)
(garray/defaultCompare x y)
(throw (js/Error. (str "Cannot compare " x " to " y))))
garray/defaultCompare
works great between numbers and goog.math.Long
or goog.math.Integer
, but we can’t get there with this branch
int?
and pos-int?
check for these types, so perhaps the right side should check for them here too?
(unfortunately I still had to make a new compare
implementation in sicmutils, because with the special case for number?
there is no way to get a number to compare to a js/BigInt
instance. These also work well with garray/defaultCompare
, but we don’t speak js/BigInt
anywhere else so I wouldn’t expect that to come in. If the number?
case were removed and fell through to a new -equiv
implementation for numbers, however, then I could override that.
might be worth taking this to http://ask.clojure.org or direct jia issue. stuff tends to get lost in slack.
I didn't find anything about that so I don't think so, but is it possible to obtain a list of original names -> munged names after advanced compilation?
Depending on what you need this for, I use https://clojurescript.org/reference/compiler-options#pseudo-names to debug advanced compilation issues.
Indeed, I forgot about source maps! That might be exactly what I need.
I’m not sure about recovering the mapping, but if you need a reliable name post-munging you can add ^:export
depending on what info you need, check out the source map files that clojurescript can produce
and https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ for interpreting the source maps