Fork me on GitHub
#cljs-dev
<
2019-05-24
>
Alex Miller (Clojure team)14:05:15

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?

dnolen14:05:23

@alexmiller I thought it "worked" already?

dnolen14:05:05

@alexmiller yes it works and we have tests

dnolen14:05:21

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

dnolen14:05:36

not a horrible limitation since in many cases that sufficient for libs

dnolen14:05:21

can probably close that ticket

dnolen15:05:26

any reason that particular ticket came up on your radar?

Alex Miller (Clojure team)15:05:42

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"

Alex Miller (Clojure team)15:05:07

which sounds suspicious :)

Alex Miller (Clojure team)15:05:07

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)

dnolen15:05:18

^ always run

Alex Miller (Clojure team)15:05:44

I'm talking about read-string

dnolen15:05:34

@alexmiller right read-string had issues with advanced compilation which we couldn't see through before

dnolen15:05:49

but this is solveable with goog.reflect

dnolen15:05:03

tools.reader could probably re-enable that test by going that route

dnolen15:05:20

read-string will try to use a name that won't exist

dnolen15:05:23

in advanced compilation

Alex Miller (Clojure team)15:05:41

as a cljs user, is there a way to make this work? (other than via register-tag-parser!)?

dnolen15:05:05

hrm I'm not sure there is an obvious way to make it work - but it should be possible yes

bronsa15:05:30

this is the initial implementation that allowed that to work, had to back it out due to advanced compilation munging

dnolen15:05:38

@alexmiller well it should be split apart really

dnolen15:05:59

since we have compiler support etc., and the advanced compilation thing is really a separate problem

dnolen15:05:25

@bronsa right but it's solveable now I believe

dnolen15:05:32

via goog.reflect

bronsa15:05:50

if you give me a hint on how to use goog.reflect I can add it back :)

dnolen15:05:05

@bronsa let me think about it and write up something

Alex Miller (Clojure team)15:05:14

is register-tag-parser! the best solution right now though?

Alex Miller (Clojure team)15:05:34

not trying to encourage either of you to do anything more on this now, just trying to solve a problem

Alex Miller (Clojure team)15:05:41

so don't do it on my account :)

bronsa15:05:00

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

Alex Miller (Clojure team)15:05:35

@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

Alex Miller (Clojure team)15:05:36

have checked obvious things like making sure code doing the register is being loaded before reading, etc

Alex Miller (Clojure team)15:05:10

maybe something changed on the printing side

Alex Miller (Clojure team)15:05:55

I'm just talking this out to myself

Alex Miller (Clojure team)15:05:39

what am I missing here?

bronsa15:05:24

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}

bronsa15:05:25

type error :)

Alex Miller (Clojure team)15:05:07

I was coming to the same conclusion from looking at the tag-table

favila16:05:02

> 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

Alex Miller (Clojure team)16:05:29

yeah, that's already sorted in this case