Skip to content

Instantly share code, notes, and snippets.

@domkm
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domkm/a92d8d33db4d8355139c to your computer and use it in GitHub Desktop.
Save domkm/a92d8d33db4d8355139c to your computer and use it in GitHub Desktop.
ClojureScript reads records as maps. Bug?
(ns namespace)
(defrecord Language [name])
(defmacro lang [name]
(->Language name))
(def clj
(lang "Clojure"))
;; Clojure reads the emission of the macro as a record
clj
;=> #namespace.Language{:name "Clojure"}
(type clj)
;=> namespace.Language
(ns namespace
(:require [cljs.reader])
(:require-macros [namespace :refer [lang]]))
(defrecord Language [name])
;; This does not fix the issue below.
; (cljs.reader/register-tag-parser! "namespace.Language" map->Language)
(def cljs
(lang "ClojureScript"))
;; ClojureScript reads the emission of the macro as a map
cljs
;=> {:name "ClojureScript"}
(type cljs)
;=> cljs.core/PersistentArrayMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment