This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-24
Channels
- # beginners (100)
- # calva (11)
- # cider (17)
- # clj-kondo (2)
- # cljdoc (66)
- # cljs-dev (54)
- # clojure (77)
- # clojure-czech (1)
- # clojure-dev (42)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-nl (17)
- # clojure-spec (12)
- # clojure-uk (41)
- # clojurescript (68)
- # cursive (8)
- # datomic (15)
- # emacs (9)
- # expound (3)
- # fulcro (14)
- # garden (3)
- # graphql (2)
- # hoplon (2)
- # lein-figwheel (4)
- # leiningen (4)
- # off-topic (22)
- # onyx (8)
- # parinfer (2)
- # planck (1)
- # re-frame (5)
- # reagent (55)
- # reitit (3)
- # remote-jobs (8)
- # shadow-cljs (35)
- # spacemacs (23)
- # sql (3)
- # tools-deps (32)
- # unrepl (8)
- # vim (25)
- # yada (5)
what's the story wrt reading record literals in edn in cljs? seems like they are not natively supported (https://clojure.atlassian.net/browse/CLJS-1328) but you could maybe pass a :default to read-string
that invoked the a.b/map->Foo
given tag "a.b.Foo"
function? or is that not possible to do in a function in cljs?
@alexmiller I thought it "worked" already?
@alexmiller yes it works and we have tests
however the limitation is that we cannot dynamically import the ns w/ that record def - so you must require it yourself before trying to use the record literal
I was not able to find such a test in clojurescript. there were some tests in tools.reader but were commented out in this commit https://github.com/clojure/tools.reader/commit/6ed0a5486f41098f3e1196cfa18f86922782955c "CLJS: disable tests for non supported features"
which sounds suspicious :)
question from a client updating to newest clojurescript - had older working version with reader/register-tag-parser!
that is not working in latest (could be some other reason too)
https://github.com/clojure/clojurescript/blob/master/src/test/cljs/data_readers_test/records.cljc
@alexmiller ^ the test
https://github.com/clojure/clojurescript/blob/master/src/test/clojure/cljs/build_api_tests.clj#L436
I'm talking about read-string
@alexmiller right read-string
had issues with advanced compilation which we couldn't see through before
as a cljs user, is there a way to make this work? (other than via register-tag-parser!)?
hrm I'm not sure there is an obvious way to make it work - but it should be possible yes
so https://clojure.atlassian.net/browse/CLJS-1328 is probably still good then
this is the initial implementation that allowed that to work, had to back it out due to advanced compilation munging
@alexmiller well it should be split apart really
since we have compiler support etc., and the advanced compilation thing is really a separate problem
is register-tag-parser! the best solution right now though?
not trying to encourage either of you to do anything more on this now, just trying to solve a problem
so don't do it on my account :)
it's always bugged me that we couldn't support it tbh, so if we now can I'm more than happy to spend some time on it
@dnolen any reason why using register-tag-parser! path for record tags would have stopped working? the original issue (didn't realize it initially) is that was how it was working, but upgrade from ~1.8 era cljs to 1.10 it stopped working, still trying to debug why
have checked obvious things like making sure code doing the register is being loaded before reading, etc
maybe something changed on the printing side
I'm just talking this out to myself
what am I missing here?
cljs.user=> (reader/register-tag-parser! 'cljs.user.R #(map->R %))
nil
cljs.user=> (reader/read-string (str "#cljs.user.R{:a 5}"))
#cljs.user.R{:a 5}
I was coming to the same conclusion from looking at the tag-table
https://clojure.atlassian.net/projects/CLJS/issues/CLJS-2540 is the other issue david mentioned
> however the limitation is that we cannot dynamically import the ns w/ that record def - so you must require it yourself before trying to use the record literal
yeah, that's already sorted in this case