Fork me on GitHub

gotcha, thank you!

Sergey Larionov05:08:23

Hello everybody, I'm learning clojure and trying to figure out some things and in shadow-cljs source I found this: Is anybody familiar with how it works? I see a lot of references to this model from all over the source but can not find a place where those functions/variables are defined. Like for example this one,


its just a namespace for keywords


(assoc db ::m/tool-id tid) is an example where m is [shadow.cljs.model :as m]

Sergey Larionov05:08:41

I see, thanks. How is it different from just :tool-id?


things like :tool-id can be very hard to find. lots of different contexts ect. adding a namespace can greatly simplify things. an example from a webapp, imagine you have routes for :user and views for :user and then objects have user. it can be quite helpful to qualify things like :transaction/user. can add some context to the notion of user. then you can easily discover other usages of users on transactions and not all users, be they users on a transaction, or a refund, or login, or email, etc.


and you can use namespace aliases for existing namespaces. and rather than type out shadow.cljs.model/tool-id the alias ::m accomplishes the same thing but with brevity for reading and writing code

Sergey Larionov05:08:09

got it, thanks. But in this particular case it seems like there is only one single namespace model for all the keywords, is that right?


@sergey.larionov yes the intent here is just to namespace keywords. the library I'm building is EQL based and uses mostly namespaced keywords. this is a good talk explaining the "why".


basically its just to make keywords more unique and I don't like to mess with too many aliases so I just group everything under one namespace. otherwise you get issues with circular dependencies and such.

Sergey Larionov11:08:32

I see, thanks a lot


Is there anything I’ve missed with the load-file ? I can call it directly, but I cannot wrap it for a forward-usage as a function.


Not really an answer to your question, but it does have an interesting comment: ;; INTERNAL - do not use, only for Node.js.


I’m using in Node.js. 😳


I don't think it automatically resolves the "INTERNAL" part. :) But it's still interesting why it wouldn't work in your scenario.


{:type :js-eval-exception, :error {:status :exception, :value "Execution error (SyntaxError) at (<cljs repl>:1).
Unexpected identifier
"}, :form (blo), :js "try{,(function (){var ret__6698__auto__ =;
(cljs.core._STAR_3 = cljs.core._STAR_2);

(cljs.core._STAR_2 = cljs.core._STAR_1);

(cljs.core._STAR_1 = ret__6698__auto__);

return ret__6698__auto__;
}catch (e18323){var e__6699__auto___18324 = e18323;
(cljs.core._STAR_e = e__6699__auto___18324);

throw e__6699__auto___18324;


But I can call it in a literal code.

(load-file "blabla.cljs")


load-file is a special form in the REPL. it cannot be used dynamically in a function.


But in Clojure parts, can do. Is this some implementation detailed block or something ? I need some hacky-trick to solve my problem, I guess.


CLJ can do it yes, CLJS cannot


I'm trying to implement assert-expr in CLJS, but I'm getting undeclared var messages..:

$ plk
ClojureScript 1.10.597
cljs.user=> (require '[clojure.test :as test])
cljs.user=> test/assert-expr
WARNING: Use of undeclared Var cljs.test/assert-expr at line 1
cljs.user=> clojure.test/assert-expr
WARNING: Use of undeclared Var cljs.test/assert-expr at line 1
cljs.user=> cljs.test/assert-expr
WARNING: Use of undeclared Var cljs.test/assert-expr at line 1
What's going on here?


@borkdude its implemented in clojure so it is on the macro side of things. in self-hosted that would be the cljs.test$macros ns


I think I implemented the multimethod in a .cljc file like so: In require:

[clojure.test :as test :refer [is]]
#?(:clj [cljs.test :as cljs-test])
One defmethod for Clojure:
defmethod test/assert-expr 'thrown-with-data?
     [msg [_ data expr]] 
And one for CLJS:
defmethod cljs-test/assert-expr 'thrown-with-data?
     [_menv msg [_ data expr]]
Yet I'm getting:
WARNING: Use of undeclared Var sci.core-test/thrown-with-data?
at the call site (only in CLJS)


Is there a cljs lib or other tool to facilitate the development of Mozilla extensions for Firefox?


Hey everyone, How do I get Cider to work with Krell? I found these instructions but I'm not sure what needs to be done here: Should it go into a file somewhere and which command would I run? Sorry for the noob question


@risto might want to ask in #cljsrn I know people did get it working, I don't use Cider just Cursive & CLI so I can't be of much help


Ah thanks I'll ask there 🙂 I found blog post, but I'm also an emacs noob too 😓 It doesn't seem to read the directory variables afaict

Sam Ritchie21:08:59

I've been working with Fraction.js to implement a ratio data type in cljs, for a generic arithmetic system; is there a way to extend some multimethod to generate instances of Fraction when the reader encounters a ratio? or is this not extensible as a user?

Sam Ritchie22:08:13

Actually, I know the answer here (I could find a way to hack it but this would make my literals unparseable by others), and I have a better solution here, I think

Sam Ritchie23:08:34

Yup, that is a good idea too for user interaction. My situation here is that the sicmutils library likes to emit these big quoted lists representing an equation, and numbers autoquote so you get ratio outputs

Sam Ritchie23:08:37

But not in CLJS. I think the elegant thing here is, implement tagged literals for the user as you suggest @alexmiller (but on the CLJS side I can’t tag an actual ratio literal, right?),

Sam Ritchie23:08:31

But then for the quoted list, have ratios emit ‘(/ numerator denominator) since that will parse into a ratio just fine, and my override of / will do the right thing in CLJS too

Sam Ritchie23:08:57

Would #ratio 1/2 work at a CLJS repl? I would think for self hosted at least, but maybe always, the inputs have to be parseable first. Could pass a string of course