Fork me on GitHub
#clojurescript
<
2021-01-13
>
suren01:01:53

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"}}}

suren01:01:56

From personal experience it does not seem to work. Just wanted to make sure its doable.

dpsutton01:01:13

it should. because everything works on a classpath. should be no difference if its in a jar in ~/.m2/repository/... or ../time-lib

suren01:01:39

Got it working, the directory structure at the local library did not match the namespace. Thanks @dpsutton

dpsutton01:01:35

glad to hear. simple tools mean that the bugs can't hide too much

šŸ‘ 3
vnctaing02:01:13

It seems like interest for clojurescript from the JS community is still dropping years after years

raspasov04:01:05

@U62LF4PT5 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

didibus05:01:43

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

seancorfield05:01:44

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?

šŸ˜® 3
didibus05:01:57

I knew something was up with it šŸ˜›

seancorfield05:01:32

It's like a subway map šŸ™‚

9
didibus05:01:51

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.

didibus05:01:13

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.

didibus05:01:52

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.

didibus05:01:47

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.

p-himik10:01:44

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.

ā˜ļø 3
borkdude11:01:49

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

borkdude11:01:18

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])

borkdude11:01:20

:thinking_face:

thheller11:01:24

can't define macros in CLJS like that. not sure about self hosted but the way above will just call it like a function

borkdude11:01:06

I did put a #?(:cljs (:require-macros [sci.impl.analyzer :refer [ctx-fn]])) in my ns decl

thheller11:01:09

not actually sure you can do this in the REPL

borkdude11:01:41

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

thheller11:01:28

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 šŸ˜‰

borkdude11:01:09

yet it does work in self-hosted when called

borkdude11:01:52

I used macrovich to solve similar issues, but this time around it doesn't seem to work

borkdude11:01:28

ah well, I got rid of the macro. less macros, less problems

šŸ˜Ž 3
Sam Ritchie19:01:37

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

thheller19:01:23

@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

Sam Ritchie19:01:09

yup, exactly, which is what I was installing

Sam Ritchie19:01:30

Ratio support, js/BigInt for two clearcut cases

Sam Ritchie19:01:00

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

Sam Ritchie19:01:43

@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

thheller19:01:50

well = is equiv

thheller19:01:01

isnt' == just a numerics things?

Sam Ritchie19:01:21

(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)))

Sam Ritchie19:01:26

not according to its implementation

Alex Miller (Clojure team)19:01:43

Behavior on non nums is undefined.
?

thheller19:01:54

its probably a function with a macro inlining stuff

thheller19:01:07

(core/defmacro ^::ana/numeric ==
  ([x] true)
  ([x y] (bool-expr (core/list 'js* "(~{} === ~{})" x y)))
  ([x y & more] `(and (== ~x ~y) (== ~y ~@more))))

thheller19:01:20

as expected uses JS === directly

Sam Ritchie19:01:55

thanks for the help sleuthing!

Sam Ritchie19:01:50

another spot that seemed like it might beg a patch was compare, which has this branch for numbers:

Sam Ritchie19:01:50

(number? x) (if (number? y)
                 (garray/defaultCompare x y)
                 (throw (js/Error. (str "Cannot compare " x " to " y))))

Sam Ritchie19:01:31

garray/defaultCompare works great between numbers and goog.math.Long or goog.math.Integer , but we canā€™t get there with this branch

Sam Ritchie19:01:24

int? and pos-int? check for these types, so perhaps the right side should check for them here too?

Sam Ritchie19:01:02

(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.

thheller19:01:38

might be worth taking this to http://ask.clojure.org or direct jia issue. stuff tends to get lost in slack.

šŸ‘ 3
Adam Helins21:01:35

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?

nnichols21:01:16

Iā€™m not sure about recovering the mapping, but if you need a reliable name post-munging you can add ^:export

phronmophobic21:01:30

depending on what info you need, check out the source map files that clojurescript can produce

danieroux09:01:31

Depending on what you need this for, I use https://clojurescript.org/reference/compiler-options#pseudo-names to debug advanced compilation issues.

Adam Helins10:01:57

Indeed, I forgot about source maps! That might be exactly what I need.