Skip to content

Commit 3657d92

Browse files
committed
Adjust documentation after changes in record meta-data and for 'record-type'.
1 parent db515a7 commit 3657d92

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ A library with various basic utilities for programming with Clojure.
55
[![Clojars Project](https://img.shields.io/clojars/v/de.active-group/active-clojure.svg)](https://clojars.org/de.active-group/active-clojure)
66
[![Actions Status](https://github.com/active-group/active-clojure/workflows/Tests/badge.svg)](https://github.com/active-group/active-clojure/actions)
77

8+
### Breaking changes in version 0.38
9+
10+
- For an RTD record `MyRecord`, `(MyRecord :meta)` will no longer
11+
return a meta data map. Use `(meta #'MyRecord)` instead.
12+
813
### Breaking changes since version `0.28.0`
914
- Clojure version 1.9.0 or higher and Clojurescript version 1.9.542 or higher
1015
are required.
@@ -180,18 +185,26 @@ You can also override the defaultly implemented interfaces/protocols by the same
180185
means. You don't have to provide every method of a default interface, those left
181186
out by you will remain the default ones.
182187

183-
#### Java Class
184-
185-
Default is `true`.
188+
#### Java Classes, RTD records
186189

187-
If you provide the key:val pair `:java-class?`:`false`, no java class is created
188-
for the given type, and instead a `record-type-descriptor` is created.
190+
By default `define-record-type` generates new types in the host
191+
language (Java for Clojure or JavaScript for ClojureScript), just
192+
like `defrecord` does. That can be changed by specifying either
193+
`:java-class? false`, or `rtd-record? true` options like so:
189194

195+
```clojure
196+
(r/define-record-type Foo {:rtd-record? true}
197+
...)
198+
```
190199

191-
#### RTD record
200+
These records have the advantage, that a hot code reload of the same
201+
definition will not create a new type in the host language. So record
202+
values created before the code reload are still compatible with the
203+
record type, unless its fields have changed of course.
192204

193-
If you provide the key:val pair `:rtd-record?`:`true`, an own record
194-
implementation for ClojureScript is used instead of `defrecord`.
205+
You cannot define protocol implementations for these kinds of record
206+
types, but you can use multi methods. Use the defined type and the
207+
result of `r/record-type` as the dispatch value for that.
195208

196209
#### Meta data
197210

@@ -200,7 +213,7 @@ MyRecord)`. This meta data is then "inherited" to all created symobls
200213
(like `->MyRecord`).
201214

202215
If you use an RTD record (`:java-class?`, `:rtd-record?` options), this data
203-
is retrievable via `(MyRecord :meta)`.
216+
is also retrievable via `(meta #'MyRecord)`.
204217

205218

206219

0 commit comments

Comments
 (0)