Support defrecord reader tags

Description

Currently, defrecord instances print similar to how they do in clojure

This representation cannot be read by the compiler, nor at runtime by cljs.reader/read-string

Analysis

The two requirements - using record literals in cljs source code and supporting runtime reading - can be addressed by using the analyzer to find defrecords and registering them with the two respective reader libraries.

Record literals

Since clojurescript reads and compiles a file at a time, clojure's behavior for literals is hard to exactly mimic. That is, to be able to use the literal in the same file where the record is defined.
A reasonable compromise might be to update the record tag table after each file has been analyzed. Thus the literal form of a record could be used only in requiring files.

EDIT: Record literals can also go into the constant pool

cljs.reader

To play well with minification, the ^:export annotation could be reused on defrecords, to publish the corresponding reader tag to cljs.reader.

Environment

None

Status

Assignee

Unassigned

Reporter

Herwig Hochleitner

Labels

Approval

None

Patch

None

Fix versions

Affects versions

Priority

Major
Configure