3 min read

On October 6, the release of Clojure 1.10.0-beta1 was announced. With this release, Clojure 1.10 will now be considered feature complete and only critical bug fixes will be addressed.

Changes introduced in Clojure 1.10

Detecting error phase

Clojure errors can occur in five distinct phases, which include read, macroexpand, compile, eval, and print. Clojure and the REPL can now identify these phases in the exception and/or the message.

The read/macroexpand/compile phases produce a CompilerException and indicate the location in the caller source code where the problem occurred. CompilerException now implements IExceptionInfo and ex-data reports exception data including the optional keys:

  • :clojure.error/source: Name of the source file
  • :clojure.error/line: Line in source file
  • :clojure.error/column: Column of line in source file
  • :clojure.error/phase: This indicates the phase (:read, :macroexpand, :compile)
  • :clojure.error/symbol – Symbol being macroexpanded or compiled

Also, clojure.main now contains a new function called ex-str that can be used by external tools to get a repl message for a CompilerException to match the clojure.main repl behavior.

Introducing tap

tap, a shared and globally accessible system, is used for distributing a series of informational or diagnostic values to a set of handler functions. It acts as a better debug prn and can also be used for facilities like logging.

Read string capture mode

A new function, read+string is added that not only mimics read, but also captures the string that is read. It then returns both the read value and the (whitespace-trimmed) read string.

prepl (alpha)

This is a new stream-based REPL with a structured output. These are the new functions that are added in clojure.core.server:

  • prepl: It is a REPL with structured output (for programs).
  • io-prepl: A prepl bound to *in* and *out* suitable for use with the Clojure socket server.
  • remote-prepl: A prepl that can be connected to a remote prepl over a socket.

prepl is now alpha and subject to change.

Java 8 or above required

Clojure 1.10 now requires Java 8 or above. The following are few of the updates related to this change and Java compatibility fixes for Java 8, 9, 10, and 11:

  • Java 8 is now the minimum requirement for Clojure 1.10
  • Embedded ASM is updated to 6.2
  • Reliance on jdk166 jar is removed
  • ASM regression is fixed
  • Invalid bytecode generation for static interface method calls in Java 9+ is now fixed
  • Reflection fallback for –illegal-access warnings in Java 9+ is added
  • Brittle test that fails on Java 10 build due to serialization drift is fixed
  • Type hint is added to address reflection ambiguity in JDK 11

Other new functions in core

To increase the portability of the error-handling code, the following functions have been added:

  • ex-cause: To extract the cause exception
  • ex-message: To extract the cause message

To know more about the changes in Clojure 1.10, check out its GitHub repository.

Read Next

Vue.js 3.0 is ditching JavaScript for TypeScript. What else is new?

Java 11 is here with TLS 1.3, Unicode 11, and more updates

Rust 2018 RC1 now released with Raw identifiers, better path clarity, and other changes


Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.

* indicates required