This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-22
Channels
- # babashka (2)
- # beginners (81)
- # calva (5)
- # chlorine-clover (3)
- # cider (1)
- # cljsjs (1)
- # cljsrn (24)
- # clojure (67)
- # clojure-europe (3)
- # clojurescript (37)
- # code-reviews (2)
- # conjure (12)
- # core-async (4)
- # datalog (1)
- # datomic (6)
- # emacs (2)
- # figwheel-main (1)
- # graalvm (12)
- # java (4)
- # kaocha (9)
- # meander (3)
- # other-lisps (1)
- # pathom (14)
- # re-frame (2)
- # sci (32)
- # shadow-cljs (77)
- # sql (88)
- # xtdb (54)
Hello everybody, I'm learning clojure and trying to figure out some things and in shadow-cljs source I found this: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/model.cljc#L1 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, https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/main.cljs#L58
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
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". https://www.youtube.com/watch?v=IS3i3DTUnAI
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.
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 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{cljs.core.pr_str.call(null,(function (){var ret__6698__auto__ = track.core.blo.call(null);
(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;
}"}
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.
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])
nil
cljs.user=> test/assert-expr
^
WARNING: Use of undeclared Var cljs.test/assert-expr at line 1
nil
cljs.user=> clojure.test/assert-expr
^
WARNING: Use of undeclared Var cljs.test/assert-expr at line 1
nil
cljs.user=> cljs.test/assert-expr
^
WARNING: Use of undeclared Var cljs.test/assert-expr at line 1
nil
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?
Got it to work now (this post was helpful: https://seespotcode.net/2018/01/13/portable-clojure-test-assert-expr/)
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: https://github.com/vouch-opensource/krell/wiki/Tooling-Integration---Emacs%2C-Cursive%2C-VSCode-etc.#nrepl-emacs-etc 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 https://increasinglyfunctional.com/2020/05/07/clojurescript-react-native-krell-emacs.html blog post, but I'm also an emacs noob too 😓 It doesn't seem to read the directory variables afaict
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?
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
Tagged literal?
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
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?),
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
Not too bad
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