Fork me on GitHub

Can be used in a cljsbuid + figwheel project? I guess not given but also I'd be surprised a whole language feature simply isn't supported

Mario C.05:08:31

How do I print one of these guys? #<[object Object]>



👍 4
Petrus Theron08:08:37

How do I unwrap optionally quoted EDN literals as user input in ClojureScript using read-string? E.g. (cljs.reader/read-string "'[1 2 3]") returns ' and not (quote [1 2 3]) as I would expect, but I'm interested in [1 2 3]. The user can also input "[1 2 3]" and I want the same output. Do I need to parse result and look for the presence of the quote symbol?

Petrus Theron08:08:39

I made a Cljs tool that translates boot-clj and Leiningen :dependencies to the newer deps.edn format: (source on GitHub)

Petrus Theron08:08:05

@U04V70XH6 thx for boot-tools-deps 🙂


Hello, I’m trying to use js* with a composed string as argument but I got Invalid js* form error. I’m not sure if what I’m doing is possible.. This works (js* "require('nano')(url:'')") but this one not (js* (str "require('nano')" "(url:'')")) . Of course I want to get the IP part from a configuration file, so as a variable. Thanks


@paolo.galizzi whats the point of using js*? just do (let [nano (js/require "nano")] (nano #js {:url the-ip}))


or better yet (ns ... (:require ["nano" :as nano])) (def the-thing (nano #js {:url ...}))


Mmm good point…there isn’t a really reason why I was using js*.. I’ll try as you suggest..thanks!


js* is an implementation detail and should never be used directly


Relating this to closurescript-beginners; is there a faq that covers all aspects of initializing a CLJS project, covering shadow, cursive, cider, lein, clj-tools, boot and god knows what else there is?


I’d like to contribute, if this is possible


Or perhaps just a list of repositories where each entry is sanctioned by the respective author of above mentioned, I don’t know what to call it, complecting element in the CLJS universe? ;-)


Personally I’d like a map of the current landscape and how/where the pieces have an effect in the process of developing


@schpaencoder: I haven't seen anything like this. I've followed this which is a good intro to shadow-cljs: purelyfunctional courses by Eric are awesome. But such resources are few and far between. Frankly, my experience is that clj/cljs is not newb friendly. cljs more so. The only exception I found so far is re-frame which has great documentation. There seems to be no one-place where all aspects of a non-trivial cljs (with clj) project are discussed. It feels like clj/cljs stuff is done by very smart people who don't have time to do handholding. clj/cljs entry skill level requirement is very very high.


Luminus tries, but is not perfect.


For me, luminus has been the only thing that let me actually do something in clojure without making me go completely insane


@dumrat great course, I learned a new thing too, how you have to tell shadow what nrepl to use, and that I have to revisit atom, because yum those in-line error messages


I would like to think that everything in Clojure-land is composable, however, only the toolmakers know how


@dumrat first time I’ve noticed the name luminous as well, thanks


Suddenly I remembered why I ditched atom. Using 300% of my cpu while idle.

👍 4
😱 4
💯 4

hi all, not sure if it's the right place to ask re-frame question but I will give it a go. Do you know if its possible to trigger multiple events in re-frame, from an event handler? The :dispatch keyword takes a vector with only one event as far as I know. Is this even an acceptable pattern?


@nustiudinastea: You can use dispatch-n. As far as I remember, it goes like this:

 [_ _]
 {:dispatch-n [[::event-1 args]
               [::event-2 args]]})


ohh snap, didn't know about :dispatch-n. Will look it up, thanks so much!


@dumrat dispatch-n works beautifully. Thanks for the tip


> Can be used in a cljsbuid + figwheel project? Any luck with this one?


I tried this in shadow-cljs as well and didn’t have any luck 😞


there seems to be very little info on tagged literals in general

😶 4

they are intentionelly not supported in shadow-cljs in .cljs source files. if you just want to use tagged literals in EDN thats fine and works via cljs.reader/register-tag-parser!


> they are intentionelly not supported @thheller interesting! what's the reasoning behind?


caching nightmares. its basically impossible to have reliable caching with those in place.

👍 4

and they are also quite annoying in to use in actual source code IMHO


better to just require a ns and use (that-ns/foo ....) than rely on some compiler magic and use #that-ns/foo ...


@mfikes made a good point about their use in the REPL though. so I will probably enable them there


> better to just require a ns my use case was to create a #bigdec, which could resolve to the implementation du jour (transit, big.js) as they are always subject to change of course one could create a fn for that (Adapter pattern), but seems overly verbose for such a basic notion (big decimals)


I think its unlikely that you'd actually be able to swap the entire implementation by just switching the reader literal


since you'll still need some other ops to actually do something with them


That's right. At least some verbosity is killed


in general it seems important that values look like 'values' , not like function calls

Mario C.16:08:28

I noticed a function defined as so: (defn funny-looking ( . . . )) This is the first time I see a function defined without an argument list. I know its not a type-o because the app is working as intended. But what is the difference from a normal function defined as (defn serious-looking [] ( . . . )) ?


That's a multi-arity function

👍 4

@mario.cordova.862 probably looking at a multi-arity fn? (defn foo ([] ...) ([a] ...))?

👍 4

Yeah @vemv, I felt that the ability to have ratio value literals could be useful:

✌️ 4

From what I see so far, I don’t know that you can effectively use resolve calls during macroexpansion-time when using macros in CLJS - I may be wrong, so seeing if anyone can shed some light on the situation. Consider this: foo/mac.clj

(ns foo.mac)
(def a "hello")
(defmacro foo [] [(resolve 'a)])
(ns (:require-macros [foo.mac :as f]))
(println  (f/foo))
I get something like [nil].


Trying to track through the CLJS compiler and analyzer to see what is going on during macroexpansion, and I belive it is due to *ns* being boudn to cljs.user during resolve being called at macroexpansion time


What isn’t clear to me, is if you can even effect that behavior in the analyzer


In particular, when I get about as deep as cljs.compiler/emit-source, there is a direct binding to ana/*cljs-ns* 'cljs.user This is then used in cljs.analyzer/macroexpand-1* via binding [*ns* (create-ns *cljs-ns*)] resulting in the *ns* being bound to cljs.user when the macro fn is called.


since cljs.compiler/emit-source doesn’t appear to yield to any passed down “compile env” to bind ana/*cljs-ns* to, I think there isn’t a effectively way to instead bind ana/*cljs-ns* to the CLJ namespace that the macro was written in. This may be a known limitation. It’d be good to hear more about it though. I couldn’t find anything related on this topic doing searches.


@mikerod *ns* is always bound to the current namespace, not where the macro was written


so while there might be an issue that’s also how *cljs-ns* should work


I don’t know that there’s a good way to do what you’re talking about even in Clojure


@dnolen ah yeah, I guess I tried to get too fancy in my example, but consider trying to resolve something from clojure.core - that also doesn’t work in CLJS


and in Clojure it would, but I think I can accept the general idea though that doing macroexpansion time resolve (or similar) can be risky


I think it should just be fully-qualifying the symbols and maybe that’d be it. so (resolve 'foo.mac/a) instead


you can use resolve, look at the cljs.spec.alpha macros, they need to do this


@dnolen You are referring to using cljs.analyzer.api/resolve like in cljs.spec.alpha/exercise-fn ?


The Graal.JS REPL has landed on ClojureScript master.

{:deps {org.clojure/clojurescript {:git/url ""
                                   :sha "04e6bd9073daa905543d7decab95a2252c2e53e2"}}}
$ clj -m cljs.main -re graaljs -r
Checking out:  at 04e6bd9073daa905543d7decab95a2252c2e53e2
cljs.user=> (.eval js/Polyglot "R" "sum(1:100)")
cljs.user=> (.eval js/Polyglot "ruby" "(1..100).reduce(:+)")
You need to have Graal Java in path for this
$ java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
GraalVM 1.0.0-rc4 (build 25.71-b01-internal-jvmci-0.45, mixed mode)

👏 20

That polyglot stuff is giving me chills, so much potential!