Vincent Chen <
nood...@gmail.com> writes:
> - Use something else than records to model structs (suggestions welcome)?
Maps.
Records have concrete Java types, which allows them to implement
interfaces and participate in protocols. Fields defined on a record
type are backed by JVM object fields, which can increase performance.
But there are no strictness benefits – a record may have any number of
additional keys associated to values:
(defrecord Foo [bar])
;;=> user.Foo
(map->Foo {:bar 1, :baz 2})
;;=> #user.Foo{:bar 1, :baz 2}
(class (map->Foo {:bar 1, :baz 2}))
;;=> user.Foo
So my suggestion would be to instead turn your `struct` definitions into
functions validating that the expected fields are present within plain
maps. (Assuming some sort of strictness/validation is the goal.)
-Marshall