This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-21
Channels
- # ai (1)
- # announcements (18)
- # aws (7)
- # babashka (54)
- # babashka-sci-dev (6)
- # beginners (22)
- # calva (57)
- # cider (3)
- # clj-http (1)
- # clojure (144)
- # clojure-austin (1)
- # clojure-dev (38)
- # clojure-europe (34)
- # clojure-gamedev (4)
- # clojure-norway (8)
- # clojure-uk (5)
- # clojurescript (12)
- # clr (20)
- # conjure (4)
- # data-science (1)
- # emacs (30)
- # events (1)
- # graphql (9)
- # helix (7)
- # hyperfiddle (22)
- # introduce-yourself (4)
- # jobs (1)
- # leiningen (7)
- # malli (3)
- # off-topic (26)
- # polylith (26)
- # portal (5)
- # random (14)
- # shadow-cljs (113)
- # tools-deps (6)
- # xtdb (9)
So I'm having trouble using a custom tagged literal in a node repl. Tag reader works fine on the jvm side:
> #voc/dstr "1^^xsd:int"
#voc/dstr "1^^xsd:int"
But the same invocation in a node repl (cider/nrepl)
> #voc/dstr "1^^xsd:int"
Unexpected error (ExceptionInfo) compiling at (REPL:1).
failed compiling constant: 1; ont_app.vocabulary.dstr.DatatypeStr is not a valid ClojureScript constant.
Following the stack trace, this appears to be the :default for the cljs.compiler/emit-constant* method.
> (methods cljs.compiler/emit-constant*)
{nil #object[Function],
...
ont-app.vocabulary.dstr/DatatypeStr #object[Function],
...
}
So it appears that the multimethod lookup is looking for ont_app.vocabulary.dstr.DatatypeStr
, but what's being entered in the methods map is ont-app.vocabulary.dstr/DatatypeStr
(differing on the underscore).
Oh, this is not a problem when I use the command-line repl:
$ clj -M:test -m cljs.main
> (require '[ont-app.vocabulary.core :as voc])
> (def x #voc/dstr "1^^xsd:int")
> x
#voc/dstr "1^^xsd:int"
> (type x)
ont-app.vocabulary.dstr/DatatypeStr
> (type (voc/untag x))
#object[Number]
So is this a bug, or is there some configuration I'm not doing when I invoke my node/shadow-cljs/cider?could be a few things...first though, have you read this? https://clojurescript.org/guides/reader
Yes, but let me re-read it.
so if I understand what you're saying, the problem is at the node repl, so there must be a clojurescript reader function that should be executing here. when at the cljs.main repl (`clj -M:test -m cljs.main`), that will be a clojure reader function - returning a valid clojurescript form. so quite different potentially
Here's my data_readers.cljc entry:
voc/dstr #?(:clj ont-app.vocabulary.dstr/read-DatatypeStr
:cljs ont-app.vocabulary.dstr/read-DatatypeStr-cljs
:default ont-app.vocabulary.dstr/read-DatatypeStr
)
Working off of these functions in the dstr.cljc file:
(defn read-DatatypeStr
"Returns an instance of DatatypeStr parsed from `form`
- Where:
- `form` :- `str`^^`datatype`"
^DatatypeStr [form]
yadda yadda)
(defn read-DatatypeStr-cljs
"Returns a macro expression for read-DatatypeStr suitable for insertion and interpretation in cljs source."
^DatatypeStr [form]
`(read-DatatypeStr ~form))
to recap - the node repl you're starting is something like clj -M -m cljs.main --repl-env node
? and you're saying that doesn't work, whereas the browser repl clj -M:test -m cljs.main
does work? If so I'm at a loss as to what the issue might be
clj -M:test -m cljs.main --repl-env node
seems to work as well.
Part of the problem is I don't play much on the cljs side.
No, but it looks like we have a minimal pair between executing node in cider and executing node from the command line.
I guess I'll bring this up with the #C0617A8PQ channel and see what they think.