Clojure Changelog

What's new in Clojure 1.11.1

Apr 25, 2024
  • CLJ-2701 Pin serialVersionUID for Keyword and ArraySeq back to 1.10.3 values to retain binary serialization

New in Clojure 1.11.0 RC 1 (Apr 1, 2022)

  • CLJ-2701 Pin serialVersionUID for Keyword and ArraySeq back to 1.10.3 values to retain binary serialization

New in Clojure 1.10.3 RC 1 (Feb 16, 2021)

  • Changes reverted:
  • CLJ-2564 Improve error message for case
  • Fixes:
  • CLJ-2453 Enable reader conditionals in Clojure prepl

New in Clojure 1.10.2 RC 2 (Jan 6, 2021)

  • FIXES:
  • Interop / JVM::
  • CLJ-2597 proxy should emit Java 1.8 bytecode

New in Clojure 1.10.2 RC 1 (Dec 12, 2020)

  • Fixes:
  • Interop / JVM:
  • CLJ-1472 Ensure monitor object is on stack, for verifiers
  • CLJ-2517 More fixes for invocation of static interface methods with primitive args
  • CLJ-2492 Remove uses of deprecated Class.newInstance()
  • CLJ-2534 Fix javadoc urls for JDK 11+
  • CLJ-2571 Add Throwable return type hint to ex-cause
  • CLJ-2572 Avoid reflection in clojure.data
  • CLJ-2502 Fix reflection warnings in clojure.stacktrace/print-stack-trace
  • Core:
  • CLJ-2580 Fix case expression branch analysis that resulted in compilation error
  • CLJ-2564 Improve error message for case
  • CLJ-2585 nth with not-found on regex matcher returns not-found on last group index
  • CLJ-1364 vector-of does not implement equals or hashing methods
  • CLJ-2549 vector-of does not implement IObj for metadata
  • CLJ-1187 quoted metadata on empty literal colls is lost
  • CLJ-2459 ExceptionInInitializerError if jars executed with java -jar
  • Printing:
  • CLJ-2469 Fix errors in printing some maps with namespace syntax
  • CLJ-1445 pprint doesn't print collection metadata when *print-meta* is true
  • Docstrings:
  • CLJ-2295 Eliminate duplicate doc string printing for special forms
  • CLJ-2495 prepl docstring is incorrect
  • CLJ-2169 conj has out-of-date :arglists
  • Performance:
  • CLJ-1005 Use transient map in zipmap

New in Clojure 1.10.1 (Dec 12, 2020)

  • Workaround Java Performance Regression When Loading user.clj:
  • Recent builds of Java 8 (u202), 11 (11.0.2), 12, and 13 included some changes that drastically affect optimization performance of calls from static initializers to static fields. Clojure provides support for loading code on startup from a user.clj file and this occurred in the static initializer of the Clojure runtime (RT) class and was thus affected.
  • This issue may eventually be resolved in Java, but in Clojure we have modified runtime initialization to avoid loading user.clj in a static initializer, which mitigates the case where this caused a performance degradation.
  • CLJ-2484 Significant performance regression of code loaded in user.clj in Java 8u202/11.0.
  • clojure.main Error Reporting:
  • clojure.main is frequently used as a Clojure program launcher by external tools. Previously, uncaught exceptions would be automatically printed by the JVM, which would also print the stack trace.
  • This release will now catch exceptions and use the same error triage and printing functionality as the Clojure repl. The full stack trace, ex-info, and other information will be printed to a target specified by the configuration.
  • The three available error targets are:
  • file - write to a temp file (default, falls back to stderr)
  • stderr - write to stderr stream
  • none - don't write
  • These error targets can be specified either as options to clojure.main, or as Java system properties (flags take precedence). When invoking clojure.main (or using the clj tool), use --report <target>. For Java system property, use -Dclojure.main.report=<target>.
  • CLJ-2463 Improve error printing in clojure.main with -m, -e, etc
  • CLJ-2497 Put error report location on its own line
  • CLJ-2504 Provide more options for error reporting in clojure.main
  • Fixes:
  • CLJ-2499 Some compiler expr evals report as wrong error phase
  • CLJ-2491 Updated fragile tests so Clojure test suite runs on Java 12

New in Clojure 1.10.0 Beta 2 (Oct 10, 2018)

  • Java:
  • Clojure 1.10 now requires Java 8 or above. There were a number of updates related to this change and/or Java compatibility fixes for Java 8, 9, 10, and 11:
  • CLJ-2363 Bump to Java 8 as minimum requirement, update embedded ASM to 6.2, remove reliance on jsr166 jar, update javadoc links, and remove conditional logic.
  • CLJ-2367 ASM regression fix
  • CLJ-2284 Fix invalid bytecode generation for static interface method calls in Java 9+
  • CLJ-2066 Add reflection fallback for --illegal-access warnings in Java 9+
  • CLJ-2330 Fix brittle test that fails on Java 10 build due to serialization drift
  • CLJ-2374 Add type hint to address reflection ambiguity in JDK 11
  • CLJ-2375 Fix usage of deprecated JDK apis
  • Dependencies:
  • Updated dependencies:
  • spec.alpha dependency to 0.2.176 - changes
  • core.specs.alpha dependency to 0.2.44 - changes
  • Features and major changes:
  • Error messages:
  • Clojure errors can occur in several distinct "phases" - read, macroexpand, compile, eval, and print. Clojure (and the REPL) 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 (previously macroexpansion reported the error in the macroexpansion stack). CompilerException now implements IExceptionInfo and ex-data will report 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 - phase (:read, :macroexpand, :compile)
  • :clojure.error/symbol - symbol being macroexpanded or compiled
  • clojure.main also contains a new function ex-str that can be used by external tools to get a repl message for a CompilerException to match the clojure.main repl behavior.
  • CLJ-2373 Detect phase and overhaul exception message and printing
  • CLJ-2414 Detect phase and overhaul exception message and printing
  • ap:
  • tap is a shared, globally accessible system for distributing a series of informational or diagnostic values to a set of (presumably effectful) handler functions. It can be used as a better debug prn, or for facilities like logging etc.
  • tap> sends a value to the set of taps. Taps can be added with add-tap and will be called with any value sent to tap>. The tap function may (briefly) block (e.g. for streams) and will never impede calls to tap>, but blocking indefinitely may cause tap values to be dropped. If no taps are registered, tap> discards. Remove taps with remove-tap.
  • 2.3 Read string capture mode
  • read+string is a new function that mimics read but also captures the string that is read and returns both the read value and the (whitespace-trimmed) read string. read+string requires a LineNumberingPushbackReader.
  • 2.4 prepl (alpha)
  • prepl is a new stream-based REPL with structured output (suitable for programmatic use). Forms are read from the reader, evaluated, and return data maps for the return value (if successful), output to *out* (possibly many), output to *err* (possibly many), or tap> values (possibly many).
  • New functions in clojure.core.server:
  • prepl - the repl
  • 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 alpha and subject to change.
  • datafy and nav:
  • clojure.datafy is a facility for object to data transformation. The datafy and nav functions can be used used to transform and (lazily) navigate through object graphs. The data transformation process can be influenced by consumers using protocols or metadata.
  • datafy is alpha and subject to change.
  • Other new functions in core:
  • These functions have been added to match existing functions in ClojureScript to increase the portability of error-handling code:
  • ex-cause - extract the cause exception
  • ex-message - extract the cause message
  • This function has been added to construct a PrintWriter implementation whose behavior on flush and close is provided as functions:
  • PrintWriter-on - create a PrintWriter from flush-fn and close-fn
  • Enhancements:
  • Error messages:
  • CLJ-1279 Report correct arity count for function arity errors inside macros
  • CLJ-2386 Omit ex-info construction frames
  • CLJ-2394 Warn in pst that stack trace for syntax error failed before execution
  • CLJ-2396 Omit :in clauses when printing spec function errors if using default explain printer
  • CLJ-1797 Mention cljc in error when require fails
  • CLJ-1130 Improve error message when unable to match static method
  • CLJ-2415 Error cause should always be on 2nd line of error message
  • Documentation:
  • CLJ-2044 clojure.instant - add arglist meta for functions
  • CLJ-2257 proxy - fix typo
  • CLJ-2332 remove-tap - fix repetition
  • CLJ-2122 flatten - describe result as lazy
  • Performance:
  • CLJ-1654 Reuse seq in some
  • CLJ-1366 The empty map literal is read as a different map each time
  • CLJ-2362 with-meta should return identity when new meta is identical to prior
  • Other enhancements:
  • CLJ-1209 Print ex-data in clojure.test error reports
  • CLJ-2163 Add test for var serialization
  • Fixes:
  • Collections:
  • CLJ-2297 PersistentHashMap leaks memory when keys are removed with without
  • CLJ-1587 PersistentArrayMap’s assoc doesn’t respect HASHTABLE_THRESHOLD
  • CLJ-2050 Remove redundant key comparisons in HashCollisionNode
  • CLJ-2089 Sorted colls with default comparator don’t check that first element is Comparable
  • API:
  • CLJ-2031 clojure.walk/postwalk does not preserve MapEntry type objects
  • CLJ-2349 Report correct line number for uncaught ExceptionInfo in clojure.test
  • CLJ-1764 partition-by runs infinite loop when one element of infinite partition is accessed
  • CLJ-1832 unchecked-* functions have different behavior on primitive longs vs boxed Longs
  • Other:
  • CLJ-1403 ns-resolve might throw ClassNotFoundException but should return nil
  • CLJ-2407 Fix bugs in Clojure unit tests

New in Clojure 1.10.0 Beta 1 (Oct 6, 2018)

  • Clojure 1.10 now requires Java 8 or above. There were a number of updates related to this change and/or Java compatibility fixes for Java 8, 9, 10, and 11:
  • CLJ-2363 Bump to Java 8 as minimum requirement, update embedded ASM to 6.2, remove reliance on jdk166 jar, update javadoc links, and remove conditional logic.
  • CLJ-2367 ASM regression fix
  • CLJ-2284 Fix invalid bytecode generation for static interface method calls in Java 9+
  • CLJ-2066 Add reflection fallback for --illegal-access warnings in Java 9+
  • CLJ-2330 Fix brittle test that fails on Java 10 build due to serialization drift
  • CLJ-2374 Add type hint to address reflection ambiguity in JDK 11
  • CLJ-2375 Fix usage of deprecated JDK apis
  • Updated dependencies:
  • spec.alpha dependency to 0.2.176
  • core.specs.alpha dependency to 0.2.44
  • Features and major changes:
  • Error messages:
  • Clojure errors can occur in several distinct "phases" - read, macroexpand, compile, eval, and print. Clojure (and the REPL) 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 (previously macroexpansion reported the error in the macroexpansion stack).
  • CompilerException now implements IExceptionInfo and ex-data will report 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 - phase (:read, :macroexpand, :compile)
  • :clojure.error/symbol - symbol being macroexpanded or compiled
  • clojure.main also contains a new function ex-str that can be used by external tools to get a repl message for a CompilerException to match the clojure.main repl behavior.
  • CLJ-2373 Detect phase and overhaul exception message and printing
  • tap:
  • tap is a shared, globally accessible system for distributing a series of informational or diagnostic values to a set of (presumably effectful) handler functions. It can be used as a better debug prn, or for facilities like logging etc.
  • tap> sends a value to the set of taps. Taps can be added with add-tap and will be called with any value sent to tap>. The tap function may (briefly) block (e.g. for streams) and will never impede calls to tap>, but blocking indefinitely may cause tap values to be dropped. If no taps are registered, tap> discards. Remove taps with remove-tap.
  • Read string capture mode:
  • read+string is a new function that mimics read but also captures the string that is read and returns both the read value and the (whitespace-trimmed) read string. read+string requires a LineNumberingPushbackReader.
  • prepl (alpha):
  • prepl is a new stream-based REPL with structured output (suitable for programmatic use). Forms are read from the reader, evaluated, and return data maps for the return value (if successful), output to *out* (possibly many), output to *err* (possibly many), or tap> values (possibly many).
  • New functions in clojure.core.server:
  • prepl - the repl
  • 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 alpha and subject to change.
  • Other new functions in core:
  • These functions have been added to match existing functions in ClojureScript to increase the portability of error-handling code:
  • ex-cause - extract the cause exception
  • ex-message - extract the cause message
  • This function has been added to construct a PrintWriter implementation whose behavior on flush and close is provided as functions:
  • PrintWriter-on - create a PrintWriter from flush-fn and close-fn
  • Enhancements:
  • Error messages:
  • CLJ-1279 Report correct arity count for function arity errors inside macros
  • CLJ-2386 Omit ex-info construction frames
  • CLJ-2394 Warn in pst that stack trace for syntax error failed before execution
  • CLJ-2396 Omit :in clauses when printing spec function errors if using default explain printer
  • CLJ-1797 Mention cljc in error when require fails
  • CLJ-1130 Improve error message when unable to match static method
  • Documentation:
  • CLJ-2044 clojure.instant - add arglist meta for functions
  • CLJ-2257 proxy - fix typo
  • CLJ-2332 remove-tap - fix repetition
  • CLJ-2122 flatten - describe result as lazy
  • Performance:
  • CLJ-1654 Reuse seq in some
  • CLJ-1366 The empty map literal is read as a different map each time
  • CLJ-2362 with-meta should return identity when new meta is identical to prior
  • Other enhancements:
  • CLJ-1209 Print ex-data in clojure.test error reports
  • CLJ-2163 Add test for var serialization
  • Fixes:
  • Collections:
  • CLJ-2297 PersistentHashMap leaks memory when keys are removed with without
  • CLJ-1587 PersistentArrayMap’s assoc doesn’t respect HASHTABLE_THRESHOLD
  • CLJ-2050 Remove redundant key comparisons in HashCollisionNode
  • CLJ-2089 Sorted colls with default comparator don’t check that first element is Comparable
  • API:
  • CLJ-2031 clojure.walk/postwalk does not preserve MapEntry type objects
  • CLJ-2349 Report correct line number for uncaught ExceptionInfo in clojure.test
  • CLJ-1764 partition-by runs infinite loop when one element of infinite partition is accessed
  • CLJ-1832 unchecked-* functions have different behavior on primitive longs vs boxed Longs
  • Other:
  • CLJ-1403 ns-resolve might throw ClassNotFoundException but should return nil
  • CLJ-2407 Fix bugs in Clojure unit tests

New in Clojure 1.9.0 (Dec 13, 2017)

  • New and Improved Features:
  • spec:
  • spec is a new core library for describing, validating, and testing the structure of data and functions.
  • 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.
  • 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.
  • New predicates:
  • Specs rely heavily on predicates and many new type and value oriented predicates have been added to clojure.core.
  • These are:
  • boolean?
  • int? pos-int? neg-int? nat-int?
  • double?
  • ident? simple-ident? qualified-ident?
  • simple-symbol? qualified-symbol?
  • simple-keyword? qualified-keyword?
  • bytes? (for byte[])
  • indexed?
  • uuid? uri?
  • seqable?
  • any?
  • More support for instants:
  • 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
  • Other new core functions:
  • 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
  • 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)
  • Enhancements:
  • 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.
  • 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
  • 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
  • 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)
  • Fixes:
  • Security:
  • CLJ-2204 Disable serialization of proxy classes to avoid potential issue when deserializing
  • Docs:
  • CLJ-2170 fix improperly located docstrings
  • CLJ-2156 clojure.java.io/copy - doc char[] support
  • CLJ-2104 clojure.pprint docstring - fix typo
  • CLJ-2051 clojure.instant/validated docstring - fix typo
  • CLJ-2039 deftype - fix typo in docstring
  • CLJ-2028 filter, filterv, remove, take-while - fix docstrings
  • CLJ-1918 await - improve docstring re shutdown-agents
  • CLJ-1873 require, *data-readers* - add .cljc files to docstrings
  • CLJ-1859 zero?, pos?, neg? - fix docstrings
  • CLJ-1837 index-of, last-index-of - clarify docstrings
  • CLJ-1826 drop-last - fix docstring
  • CLJ-1159 clojure.java.io/delete-file - improve docstring
  • 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
  • CLJ-700 contains?, get, and find broken for transient collections

New in Clojure 1.8.0 (Aug 6, 2015)

  • New and Improved Features:
  • Direct Linking:
  • This feature is a work in progress, subject to change.
  • Direct linking can be enabled with -Dclojure.compiler.direct-linking=true
  • Direct linking allows functions compiled with direct linking on to make direct static method calls to most other functions, instead of going through the var and the Fn object. This can enable further optimization by the jit, at a cost in dynamism. In particular, directly-linked calls will not see redefinitions.
  • As of 1.8.0-alpha3, clojure.core is compiled with direct linking by default and therefore other namespaces cannot redefine core fns and have those redefinitions seen by core code.
  • Functions declared as dynamic will never be direct linked.
  • Enhancements:
  • Error messages:
  • Documentation strings:
  • CLJ-1060 'list*' returns not a list
  • CLJ-1722 Typo in the docstring of 'with-bindings'
  • CLJ-1769 Docstrings for *' and +' refer to * and +
  • Performance:
  • CLJ-703 Improve writeClassFile performance
  • Other enhancements:
  • CLJ-1208 Optionally require namespace on defrecord class init
  • Bug Fixes:
  • CLJ-130 Namespace metadata lost in AOT compile
  • CLJ-1134 star-directive in clojure.pprint/cl-format with at-prefix ("~n@*") does not obey its specification
  • CLJ-1137 Metadata on a def gets evaluated twice
  • CLJ-1157 Classes generated by gen-class aren't loadable from remote codebase
  • CLJ-1225 quot overflow issues around Long/MIN_VALUE for BigInt
  • CLJ-1250 Reducer (and folder) instances hold onto the head of seqs
  • CLJ-1313 Correct a few unit tests
  • CLJ-1319 array-map fails lazily if passed an odd number of arguments
  • CLJ-1361 pprint with code-dispatch incorrectly prints a simple ns macro call
  • CLJ-1390 pprint a GregorianCalendar results in Arity exception
  • CLJ-1399 field name unmunged when recreating deftypes serialized into bytecode
  • CLJ-1485 clojure.test.junit/with-junit-output doesn't handle multiple expressions
  • CLJ-1528 clojure.test/inc-report-counter is not thread-safe
  • CLJ-1533 invokePrim path does not take into account var or form meta
  • CLJ-1562 some->,some->>,cond->,cond->> and as-> doesn't work with (recur)
  • CLJ-1565 pprint produces infinite output for a protocol
  • CLJ-1588 StackOverflow in clojure.test macroexpand with are and anon fn
  • CLJ-1644 into-array fails for sequences starting with nil
  • CLJ-1645 protocol class does not set the source file
  • CLJ-1657 proxy bytecode calls super methods of abstract classes
  • CLJ-1659 compile leaks files
  • CLJ-1761 clojure.core/run! does not always return nil per docstring
  • CLJ-1782 Spelling mistake in clojure.test/use-fixtures
  • CLJ-1785 Reader conditionals throw when returning nil

New in Clojure 1.7.0 (Aug 6, 2015)

  • Compatibility Notes:
  • Please be aware of the following issues when upgrading to Clojure 1.7.
  • Seqs on Java iterators that return the same mutating object:
  • Seqs are fundamentally incompatible with Java iterators that return the same mutating object on every call to next(). Some Clojure libraries incorrectly rely on calling seq on such iterators.
  • In 1.7, iterator-seqs are chunked, which will cause many of these incorrect usages to return incorrect results immediately.
  • The seq and iterator-seq docstrings have been updated to include an explicit warning. Libraries that incorrectly use seq and iterator-seq will need to be fixed before running against 1.7.
  • CLJ-1669
  • CLJ-1738
  • Thread owner check removed on transients:
  • Prior to Clojure 1.7, transients would allow modification only from the thread that created the transient. This check has been removed. It is still a requirement that transients should be updated by only a single thread at a time.
  • This constraint was relaxed to allow transients to be used in cases where code is multiplexed across multiple threads in a pool (such as go blocks in core.async).
  • keys/vals require custom map type to implement Iterable:
  • Invoking keys or vals on a custom map type that implements IPersistentMap will now use the Iterable iterator() method instead of accessing entries via the seq of the map. There have been no changes in the type hierarchy (IPersistentMap has always extended Iterable) but former map-like instances may have skipped implementing this method in the past.
  • CLJ-1602
  • New and Improved Features:
  • Transducers:
  • Transducers is a new way to decouple algorithmic transformations from their application in different contexts. Transducers are functions that transform reducing functions to build up a "recipe" for transformation.
  • Many existing sequence functions now have a new arity (one fewer argument than before). This arity will return a transducer that represents the same logic but is independent of lazy sequence processing. Functions included are:
  • map
  • mapcat
  • filter
  • remove
  • take
  • take-while
  • drop
  • drop-while
  • take-nth
  • replace
  • partition-by
  • partition-all
  • keep
  • keep-indexed
  • map-indexed
  • distinct
  • interpose
  • Additionally some new transducer functions have been added:
  • cat - concatenates the contents of each input
  • dedupe - removes consecutive duplicated values
  • random-sample - returns items from coll with random probability
  • And this function can be used to make completing transforms:
  • completing
  • There are also several new or modified functions that can be used to apply transducers in different ways:
  • sequence - takes a transformation and a coll and produces a lazy seq
  • transduce - reduce with a transformation (eager)
  • eduction - returns a reducible/iterable of applications of the transducer to items in coll. Applications are re-performed with every reduce/iterator.
  • There have been a number of internal changes to support transducers:
  • volatiles - there are a new set of functions (volatile!, vswap!, vreset!, volatile?) to create and use volatile "boxes" to hold state in stateful transducers. Volatiles are faster than atoms but give up atomicity guarantees so should only be used with thread isolation.
  • array iterators - added support for iterators over arrays
  • conj can be used as a reducing function and will conj to []
  • Some related issues addressed during development:
  • CLJ-1511
  • CLJ-1497
  • CLJ-1549
  • CLJ-1537
  • CLJ-1554
  • CLJ-1601
  • CLJ-1606
  • CLJ-1621
  • CLJ-1600
  • CLJ-1635
  • CLJ-1683
  • CLJ-1669
  • CLJ-1723
  • Reader Conditionals:
  • Reader Conditionals are a new capability to support portable code that can run on multiple Clojure platforms with only small changes. In particular, this feature aims to support the increasingly common case of libraries targeting both Clojure and ClojureScript.
  • Code intended to be common across multiple platforms should use a new supported file extension: ".cljc". When requested to load a namespace, the platform-specific file extension (.clj, .cljs) will be checked prior to .cljc.
  • A new reader form can be used to specify "reader conditional" code in cljc files (and only cljc files). Each platform defines a feature identifying the platform (:clj, :cljs, :cljr). The reader conditional specifies code that is read conditionally based on the feature. The REPL also allows reader conditionals.
  • Form #? takes a list of alternating feature and expression. These are checked like cond and the selected expression is read and returned. Other branches are read but skipped. If no branch is selected, the reader reads nothing (not nil, but literally as if reading no form). An optional :default branch can be used as a fall through.
  • Reader conditional with 2 features and a default:
  • #?(:clj Double/NaN
  • :cljs js/NaN
  • :default nil)
  • There is also a reader conditional splicing form. The evaluated expression should be sequential and will be spliced into the surrounded code, similar to unquote-splicing.
  • For example
  • [1 2 #?@(:clj [3 4] :cljs [5 6])]
  • This form would read as [1 2 3 4] on Clojure, [1 2 5 6] on ClojureScript, and [1 2] on any other platform. Splicing is not allowed at the top level.
  • Additionally, the reader can now be invoked with options for the features to use and how to interpret reader conditionals. By default, reader conditionals are not allowed, but that can be turned on, or a "preserve" mode can be used to preserve all branches (most likely useful for tooling or source transforms).
  • In the preserve mode, the reader conditional itself and any tagged literals within the unselected branches are returned as tagged literal data.
  • CLJ-1424
  • CLJ-1685
  • CLJ-1698
  • CLJ-1699
  • CLJ-1700
  • CLJ-1728
  • CLJ-1706
  • Keyword and Symbol Construction:
  • In response to issues raised in CLJ-1439, several changes have been made in symbol and keyword construction:
  • 1) The main bottleneck in construction of symbols (which also occurs inside keywords) was interning of the name and namespace strings. This interning has been removed, resulting in a performance increase.
  • 2) Keywords are cached and keyword construction includes a cache check. A change was made to only clear the cache reference queue when there is a cache miss.
  • Warn on Boxed Math:
  • One source of performance issues is the (unintended) use of arithmetic operations on boxed numbers. To make detecting the presence of boxed math easier, a warning will now be emitted about boxed math if *unchecked-math* is set to :warn-on-boxed (any truthy value will enable unchecked-math, only this specific value enables the warning).
  • CLJ-1325
  • CLJ-1535
  • CLJ-1642
  • update - like update-in for first level:
  • update is a new function that is like update-in specifically for first-level keys:
  • (update m k f args...)
  • CLJ-1251
  • Faster reduce and iterator paths:
  • Several important Clojure functions now return sequences that also contain fast reduce() (or in some cases iterator()) paths. In many cases, the new implementations are also faster for lazy sequences
  • repeat - now implements IReduce
  • cycle - implements IReduceInit
  • iterate - implements IReduceInit
  • range - implements IReduce, specialized case handles common case of all longs
  • keys - iterates directly over the keys of a map, without seq or MapEntry allocation
  • vals - iterates directly over the vals of a map, without seq or MapEntry allocation
  • iterator-seq - creates a chunked sequence when previously it was unchunked
  • Additionally, hash-maps and hash-sets now provide iterators that walk the data structure directly rather than via a sequence.
  • A new interface (IMapIterable) for direct key and val iterators on maps was added. External data structures can use this interface to provide direct key and val iterators via keys and vals.
  • These enhancements are particularly effective when used in tandem with transducers via transduce, sequence, into, and eduction.
  • CLJ-1603
  • CLJ-1515
  • CLJ-1602
  • CLJ-1669
  • CLJ-1692
  • CLJ-1694
  • CLJ-1711
  • CLJ-1709
  • CLJ-1713
  • CLJ-1726
  • CLJ-1727
  • Printing as data:
  • There have been enhancements in how the REPL prints values without a print-method, specifically Throwable and the fall through Object case. Both cases now print in a tagged literal data form that can be read by the reader.
  • Unhandled objects print with the class, hash code, and toString:
  • user=> *ns*
  • #object[clojure.lang.Namespace 0x55aa628 "user"]
  • Thrown exceptions will still be printed in the normal way by the default REPL but printing them to a stream will show a different form:
  • user=> (/ 1 0)
  • ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:158)
  • user=> (println *e)
  • #error {
  • :cause Divide by zero
  • :via
  • [{:type java.lang.ArithmeticException
  • :message Divide by zero
  • :at [clojure.lang.Numbers divide Numbers.java 158]}]
  • :trace
  • [[clojure.lang.Numbers divide Numbers.java 158]
  • [clojure.lang.Numbers divide Numbers.java 3808]
  • ;; ... elided frames
  • Additionally, there is a new function available to obtain a Throwable as map data: Throwable->map.
  • CLJ-1703
  • CLJ-1716
  • CLJ-1735
  • run!:
  • run! is a new function that takes a side effect reducing function and runs it for all items in a collection via reduce. The accumulator is ignored and nil is returned.
  • (run! println (range 10))
  • Enhancements:
  • Error messages:
  • CLJ-1261 Invalid defrecord results in exception attributed to consuming ns instead of defrecord ns
  • CLJ-1297 Give more specific hint if namespace with "-" not found to check file uses "_"
  • Documentation strings:
  • CLJ-1417 clojure.java.io/input-stream has incorrect docstring
  • CLJ-1357 Fix typo in gen-class doc-string
  • CLJ-1479 Fix typo in filterv example
  • CLJ-1480 Fix typo in defmulti docstring
  • CLJ-1477 Fix typo in deftype docstring
  • CLJ-1478 Fix typo in clojure.main usage
  • CLJ-1738 Clarify usage on Java iterators in seq and iterator-seq
  • Performance:
  • CLJ-1430 Improve performance of partial with more unrolling
  • CLJ-1384 clojure.core/set should use transients for better performance
  • CLJ-1429 Cache unknown multimethod value default dispatch
  • CLJ-1529 Reduce compile times by avoiding unnecessary calls to Class.forName()
  • CLJ-1546 vec is now faster on almost all inputs
  • CLJ-1618 set is now faster on almost all inputs
  • CLJ-1695 Fixed reflection call in variadic vector-of constructor
  • Other enhancements:
  • CLJ-1191 Improve apropos to show some indication of namespace of symbols found
  • CLJ-1378 Hints don't work with #() form of function
  • CLJ-1498 Removes owner-thread check from transients - this check was preventing some valid usage of transients in core.async where a transient is created on one thread and then used again in another pooled thread (while still maintaining thread isolation).
  • CLJ-803 Extracted IAtom interface implemented by Atom.
  • CLJ-1315 Don't initialize classes when importing them
  • CLJ-1330 Class name clash between top-level functions and defn'ed ones
  • CLJ-1349 Update to latest test.generative and add dependency on test.check
  • CLJ-1546 vec now works with things that only implement Iterable or IReduceInit
  • CLJ-1618 set now works with things that only implement Iterable or IReduceInit
  • CLJ-1633 PersistentList/creator doesn't handle ArraySeqs correctly
  • CLJ-1589 Clean up unused paths in InternalReduce
  • CLJ-1677 Add setLineNumber() to LineNumberingPushbackReader
  • CLJ-1667 Change test to avoid using hard-coded socket port
  • CLJ-1683 Change reduce tests to better catch reduce without init bugs
  • Bug Fixes:
  • Asd
  • CLJ-1362 Reduce broken on some primitive vectors
  • CLJ-1388 Equality bug on records created with nested calls to map->record
  • CLJ-1274 Unable to set compiler options via system properties except for AOT compilation
  • CLJ-1241 NPE when AOTing overrided clojure.core functions
  • CLJ-1185 reductions does not check for reduced value
  • CLJ-1039 Using def with metadata {:type :anything} throws ClassCastException during printing
  • CLJ-887 Error when calling primitive functions with destructuring in the arg vector
  • CLJ-823 Piping seque into seque can deadlock
  • CLJ-738

New in Clojure 1.6.0 (Aug 7, 2014)

  • COMPATIBILITY AND DEPENDENCIES:
  • JDK Version Update:
  • Clojure now builds with Java SE 1.6 and emits bytecode requiring Java SE 1.6 instead of Java SE 1.5. [CLJ-1268]
  • ASM Library Update:
  • The embedded version of the ASM bytecode library has been upgraded to ASM 4.1. [CLJ-713]
  • Promoted "Alpha" Features:
  • Watches - add-watch, remove-watch
  • Transients - transient, persistent!, conj!, assoc!, dissoc!, pop!, disj!
  • Exception data - ex-info, ex-data
  • Promises - promise, deliver
  • Records - defrecord
  • Types - deftype
  • Pretty-print tables - print-table
  • NEW AND IMPROVED FEATURES:
  • Java API:
  • The clojure.java.api package provides a minimal interface to bootstrap Clojure access from other JVM languages. It does this by providing: 1. The ability to use Clojure's namespaces to locate an arbitrary var, returning the var's clojure.lang.IFn interface. 2. A convenience method read for reading data using Clojure's edn reader.
  • Map destructuring extended to support namespaced keys:
  • In the past, map destructuring with :keys and :syms would not work with maps containing namespaced keys or symbols. The :keys and :syms forms have been updated to allow them to match namespaced keys and bind to a local variable based on the name.
  • New "some" operations:
  • Many conditional functions rely on logical truth (where "falsey" values are nil or false). Sometimes it is useful to have functions that rely on "not nilness" instead.
  • Hashing:
  • Clojure 1.6 provides new hashing algorithms for primitives and collections, accessible via IHashEq/hasheq (in Java) or the clojure.core/hash function (in Clojure). In general, these changes should be transparent to users, except hash codes used inside hashed collections like maps and sets will have better properties.
  • bitops:
  • A new unsigned-bit-shift-right (Java's >>>) has been added to the core library. The shift distance is truncated to the least 6 bits (per the Java specification for long >>>).
  • clojure.test:
  • Added a new clojure.test/test-vars function that takes a list of vars, groups them by namespace, and runs them with their fixtures.
  • ENHANCEMENTS:
  • Printing:
  • CLJ-908 Print metadata for functions when print-meta is true and remove errant space at beginning.
  • CLJ-937 pprint cl-format now supports E, F, and G formats for ratios.
  • Error messages:
  • CLJ-1248 Include type information in reflection warning messages
  • CLJ-1099 If non-seq passed where seq is needed, error message now is an ExceptionInfo with the instance value, retrievable via ex-data.
  • CLJ-1083 Fix error message reporting for "munged" function names (like a->b).
  • CLJ-1056 Handle more cases and improve error message for errors in defprotocol definitions.
  • CLJ-1102 Better handling of exceptions with empty stack traces.
  • CLJ-939 Exceptions thrown in the top level ns form are reported without file or line number.
  • Documentation strings:
  • CLJ-1164 Fix typos in clojure.instant/validated and other internal instant functions.
  • CLJ-1143 Correct doc string for ns macro.
  • CLJ-196 Clarify value of file is undefined in the REPL.
  • CLJ-1228 Fix a number of spelling errors in namespace and doc strings.
  • CLJ-835 Update defmulti doc to clarify expectations for hierarchy argument.
  • CLJ-1304 Fix minor typos in documentation and comments
  • CLJ-1302 Mention that keys and vals order are consistent with seq order
  • Performance:
  • CLJ-858 Improve speed of STM by removing System.currentTimeMillis.
  • CLJ-669 clojure.java.io/do-copy: use java.nio for Files
  • commit Reduce overhead of protocol callsites by removing unneeded generated cache fields.
  • Other enhancements:
  • CLJ-908 Make default-data-reader-fn set!-able in REPL, similar to data-readers.
  • CLJ-783 Make clojure.inspector/inspect-tree work on sets.
  • CLJ-896 Make browse-url aware of xdg-open.
  • CLJ-1160 Fix clojure.core.reducers/mapcat does not stop on reduced? values.
  • CLJ-1121 -> and ->> have been rewritten to work with a broader set of macros.
  • CLJ-1105 clojure.walk now supports records.
  • CLJ-949 Removed all unnecessary cases of sneakyThrow.
  • CLJ-1238 Allow EdnReader to read foo// (matches LispReader behavior).
  • CLJ-1264 Remove uses of _ as a var in the Java code (causes warning in Java 8).
  • CLJ-394 Add record? predicate.
  • CLJ-1200 ArraySeq dead code cleanup, ArraySeq_short support added.
  • CLJ-1331 Primitive vectors should implement hasheq and use new hash algorithm
  • CLJ-1354 Make APersistentVector.SubVector public so other collections can access
  • CLJ-1353 Make awt run headless during the build process
  • BUG FIXES:
  • CLJ-1018 Make range consistently return infinite sequence of start with a step of 0.
  • CLJ-863 Make interleave return () on 0 args and identity on 1 args.
  • CLJ-1072 Update internal usages of the old metadata reader syntax to new syntax.
  • CLJ-1193 Make bigint and biginteger functions work on double values outside long range.
  • CLJ-1154 Make Compile.java flush but not close stdout so errors can be reported.
  • CLJ-1161 Remove bad version.properties from sources jar.
  • CLJ-1175 Fix invalid behavior of Delay/deref if an exception is thrown - exception will now be rethrown on subsequent calls and not enter a corrupted state.
  • CLJ-1171 Fix several issues with instance? to make it consistent when used with apply.
  • CLJ-1202 Protocol fns with dashes may get incorrectly compiled into field accesses.
  • CLJ-850 Add check to emit invokePrim with return type of double or long if type-hinted.
  • CLJ-1177 clojure.java.io URL to File coercion corrupts path containing UTF-8 characters.
  • CLJ-1234 Accept whitespace in Record and Type reader forms (similar to data literals).
  • CLJ-1233 Allow ** as a valid symbol name without triggering dynamic warnings.
  • CLJ-1246 Add support to clojure.reflect for classes with annotations.
  • CLJ-1184 Evaling #{do ...} or [do ...] is treated as do special form.
  • CLJ-1090 Indirect function calls through Var instances fail to clear locals.
  • CLJ-1076 pprint tests fail on Windows, expecting \n.
  • CLJ-766 Make into-array work consistently with short-array and byte-array on bigger types.
  • CLJ-1285 Data structure invariants are violated after persistent operations when collision node created by transients.
  • CLJ-1222 Multiplication overflow issues around Long/MIN_VALUE
  • CLJ-1118 Inconsistent numeric comparison semantics between BigDecimals and other numerics
  • CLJ-1125 Clojure can leak memory in a servlet container when using dynamic bindings or STM transactions.
  • CLJ-1082 Subvecs of primitve vectors cannot be reduced
  • CLJ-1301 Case expressions use a mixture of hashCode and hasheq, potentially leading to missed case matches when these differ.
  • CLJ-983 proxy-super does not restore original binding if call throws exception
  • CLJ-1176 clojure.repl/source errors when read-eval bound to :unknown
  • CLJ-935 clojure.string/trim uses different definition of whitespace than triml and trimr
  • CLJ-1058 StackOverflowError on exception in reducef for PersistentHashMap fold
  • CLJ-1328 Fix some tests in the Clojure test suite to make their names unique and independent of hashing order
  • CLJ-1339 Empty primitive vectors throw NPE on .equals with non-vector sequential types
  • CLJ-1363 Field access via .- in reflective case does not work
  • CLJ-944 Compiler gives constant collections types which mismatch their runtime values
  • CLJ-1387 reduce-kv on large hash maps ignores reduced result