[ANN] Clojure 1.9.0-beta1 is now available

2,073 views
Skip to first unread message

Alex Miller

unread,
Sep 18, 2017, 1:31:00 PM9/18/17
to Clojure
Changes to Clojure in Version 1.9.0-beta1 (since 1.8.0)


1 New and Improved Features


1.1 spec

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.

1.2 Support for working with maps with qualified keys

Several enhancements have been made to add support for working with maps with qualified keys:

  • Map namespace syntax - specify the default namespace context for the keys (or symbols) in a map once - #:car{:make "Jeep" :model "Wrangler"}. For more information see https://clojure.org/reference/reader#_maps(CLJ-1910)
  • Destructuring support - namespaced map keys can now specified once as a namespace for :keys or :syms. For more information see https://clojure.org/reference/special_forms#_map_binding_destructuring (CLJ-1919)
  • *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.

1.3 New predicates

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?

1.4 More support for instants

More support has been added for the notion of instants in time:

  • Added a new protocol Inst for instant types
  • Inst is extended for java.util.Date
  • Inst is optionally extended for java.time.Instant in Java 1.8+
  • New functions that work for instants: inst?inst-ms

1.5 Other new core functions

These are some other new functions in clojure.core:

  • bounded-count - a count that avoids realizing the entire collection beyond a bound
  • swap-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

1.6 Other reader enhancements

  • Can now bind *reader-resolver* to an impl of LispReader$Resolver to control the reader’s use of namespace interactions when resolving autoresolved keywords and maps.
  • Add new ## reader macro for symbolic values, and read/print support for double vals ##Inf, ##-Inf, ##NaN (CLJ-1074)

2 Enhancements

2.1 Spec syntax checking

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.

2.2 Documentation

  • 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 name

2.3 Performance

  • Improved update-in performance
  • Optimized seq & destructuring
  • CLJ-2210 Cache class derivation in compiler to improve compiler performance
  • CLJ-2188 slurp - mark return type as String
  • CLJ-2070 clojure.core/delay - improve performance
  • CLJ-1917 Reducing seq over string should call String/length outside of loop
  • CLJ-1901 amap - should call alength only once
  • CLJ-1224 Record instances now cache hasheq and hashCode like maps
  • CLJ-99 min-key and max-key - evaluate k on each arg at most once

2.4 Other enhancements

  • Added Var serialization for identity, not value
  • into now has a 0-arity (returns []) and 1-arity (returns the coll that's passed)
  • CLJ-2184 Propagate meta in doto forms to improve error reporting
  • CLJ-1744 Clear unused locals, which can prevent memory leaks in some cases
  • CLJ-1673 clojure.repl/dir-fn now works on namespace aliases
  • CLJ-1423 Allow vars to be invoked with infinite arglists (also, faster)

3 Fixes

3.1 Security

  • CLJ-2204 Disable serialization of proxy classes to avoid potential issue when deserializing

3.2 Docs

3.3 Other fixes

  • clojure.core/Throwable->map formerly returned StackTraceElements 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.
  • CLJ-2091 clojure.lang.APersistentVector#hashCode is not thread-safe
  • CLJ-2077 Clojure can't be loaded from the boot classpath under java 9
  • CLJ-2048 Specify type to avoid ClassCastException when stack trace is elided by JVM
  • CLJ-1914 Fixed race condition in concurrent range realization
  • CLJ-1887 IPersistentVector.length() - implement missing method
  • CLJ-1870 Fixed reloading a defmulti removes metadata on the var
  • CLJ-1860 Make -0.0 hash consistent with 0.0
  • CLJ-1841 bean - iterator was broken
  • CLJ-1793 Clear 'this' before calls in tail position
  • CLJ-1790 Fixed error extending protocols to Java arrays
  • CLJ-1714 using a class in a type hint shouldn’t load the class
  • CLJ-1705 vector-of - fix NullPointerException if given unrecognized type
  • CLJ-1398 clojure.java.javadoc/javadoc - update doc urls
  • CLJ-1371 Numbers.divide(Object, Object) - add checks for NaN
  • CLJ-1358 doc - does not expand special cases properly (try, catch)
  • CLJ-1242 equals doesn't throw on sorted collections

Ghadi Shayban

unread,
Sep 18, 2017, 2:25:41 PM9/18/17
to Clojure
Congrats everyone! What a major release.
Reply all
Reply to author
Forward
0 new messages