spec is a new core library for describing, validating, and testing the structure of data and functions.
For more information, see:
Note that spec is in alpha state and API compatibility is not guaranteed. Also, spec and the specs for the Clojure core API are distributed as external libraries that must be included to use Clojure.
Several enhancements have been made to add support for working with maps with qualified keys:
#:car{:make "Jeep" :model "Wrangler"}
. For more information see https://clojure.org/reference/reader#_maps(CLJ-1910)*print-namespace-maps*
- by default maps will not print with the map namespace syntax except in the clojure.main repl. This dynamic var is a flag to allow you to control whether the namespace map syntax is used.Specs rely heavily on predicates and many new type and value oriented predicates have been added to clojure.core:
boolean?
int?
pos-int?
neg-int?
nat-int?
double?
bigdec?
ident?
simple-ident?
qualified-ident?
simple-symbol?
qualified-symbol?
simple-keyword?
qualified-keyword?
bytes?
(for byte[]
)indexed?
uuid?
uri?
seqable?
any?
More support has been added for the notion of instants in time:
Inst
for instant typesInst
is extended for java.util.Date
Inst
is optionally extended for java.time.Instant
in Java 1.8+inst?
, inst-ms
These are some other new functions in clojure.core:
bounded-count
- a count that avoids realizing the entire collection beyond a boundswap-vals!
and reset-vals!
- new atom functions that return both the old and new values (CLJ-1454)halt-when
- new transducer that ends transduction when pred is satisfied*reader-resolver*
to an impl of LispReader$Resolver to control the reader’s use of namespace interactions when resolving autoresolved keywords and maps.If a macro has a spec defined via fdef, that spec will be checked at compile time. Specs have been defined for many clojure.core macros and errors will be reported for these based on the specs at compile time.
doc
will now report specs for functions with specs defined using fdef
doc
can now be invoked with a fully-qualified keyword representing a spec nameslurp
- mark return type as Stringclojure.core/delay
- improve performanceamap
- should call alength only oncemin-key
and max-key
- evaluate k on each arg at most onceinto
now has a 0-arity (returns []
) and 1-arity (returns the coll that's passed)clojure.repl/dir-fn
now works on namespace aliasesclojure.java.io/copy
- doc char[] supportclojure.pprint
docstring - fix typoclojure.instant/validated
docstring - fix typodeftype
- fix typo in docstringfilter
, filterv
, remove
, take-while
- fix docstringsawait
- improve docstring re shutdown-agents
require
, *data-readers*
- add .cljc files to docstringszero?
, pos?
, neg?
- fix docstringsindex-of
, last-index-of
- clarify docstringsdrop-last
- fix docstringclojure.java.io/delete-file
- improve docstringclojure.core/Throwable->map
formerly returned StackTraceElement
s which were later handled by the printer. Now the StackTraceElements are converted to data such that the return value is pure Clojure data, as intended.clojure.lang.APersistentVector#hashCode
is not thread-saferange
realizationIPersistentVector.length()
- implement missing methoddefmulti
removes metadata on the varbean
- iterator was brokenvector-of
- fix NullPointerException if given unrecognized typeclojure.java.javadoc/javadoc
- update doc urlsNumbers.divide(Object, Object)
- add checks for NaNdoc
- does not expand special cases properly (try, catch)