Generated file. Do not edit. Regenerate with bb api-docs; check with bb api-docs --check.
See the README for examples. This library supports Clojure 1.11+ on the JVM only. ClojureScript and Babashka are not supported.
closed-record.core - Public API of closed-record: a record type that does not permit assoc of undeclared keys or dissoc of declared keys.
check - Return x if x is a closed record with no extra literal keys.defclosedrecord - (defclosedrecord Name [fields*] options* specs*) Same syntax as defrecord.Public API of closed-record: a record type that does not permit assoc of undeclared keys or dissoc of declared keys.
check(check x)
Function.
Return x if x is a closed record with no extra literal keys.
Throw ex-info with :type :closed-record/extra-keys (and :record, :keys) if x is a closed record read from a literal with undeclared keys. Throw ex-info with :type :closed-record/not-closed-record (and :value-class) for any other value, including nil.
defclosedrecord(defclosedrecord name [& fields] & opts+specs)
Macro.
(defclosedrecord Name [fields*] options* specs*)
Same syntax as defrecord. Defines a record type with closed keys:
Lookup of an undeclared key gives the not-found value. Extra keys of a
map literal #ns.Name{...} are hidden; use check to find them.
Name is the type name symbol. fields is a vector of field symbols; each field declares its corresponding keyword key. specs supplies protocol or interface names and method implementations, as in defrecord. Options are keyword/value pairs before specs. Supported options are :no-print and :load-ns, passed to the JVM type compiler as in defrecord.
Defines ->Name, which takes one value per field in declaration order, and map->Name, which takes a map of keyword keys to field values. Missing declared keys in map->Name have nil values.
Rejected operations throw ex-info. Its ex-data contains :type and :record (the record class). Rejected assoc and dissoc also include :key; map->Name includes :keys (the set of undeclared keys). dissoc of an undeclared key returns the same record.
Extra literal keys do not affect lookup, entries, equality, hash, or print. Compilation of a literal as a code constant and print/read round trips discard extra keys. Call check on a runtime-read literal before those operations; check cannot find keys that have already been discarded.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |