clojerl / clojerl

Clojure for the Erlang VM (unofficial)

Home Page:http://try.clojerl.online/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include changes from clojure-1.10.3

jfacorro opened this issue Β· comments

Once #793 is done

Go over the changelog for Clojure 1.10.0-1.10.3 and apply the changes to Clojerl.

Review the code changes by checking out tag clojure-1.10.3 and then running git dif clojure-1.9.0.

Reference:

Applicable 🟩
Maybe Applicable 🟨
Not Applicable πŸŸ₯

Changes to Clojure in Version 1.10.3

1 Changes reverted

  • CLJ-2564
    Improve error message for case 🟨

2 Fixes

  • CLJ-2453
    Enable reader conditionals in Clojure prepl 🟨

Changes to Clojure in Version 1.10.2

1 Dependencies

Updated dependencies:

  • spec.alpha dependency to 0.2.194 - changes 🟩
  • core.specs.alpha dependency to 0.2.56 - changes 🟩

2 Fixes

2.1 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 🟨
  • CLJ-2597
    proxy should emit Java 1.8 bytecode πŸŸ₯

2.2 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 πŸŸ₯
    There is no support for vector-of in Clojerl.
  • CLJ-2549
    vector-of does not implement IObj for metadata πŸŸ₯
    There is no support for vector-of in Clojerl.
  • CLJ-1187
    quoted metadata on empty literal colls is lost 🟨
  • CLJ-2459
    ExceptionInInitializerError if jars executed with java -jar πŸŸ₯

2.3 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 🟩

2.4 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 🟩

3 Performance

  • CLJ-1005
    Use transient map in zipmap 🟨

Changes to Clojure in Version 1.10.1

1 Features and Major Changes

1.1 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. πŸŸ₯

1.2 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 🟩

2 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 🟨

Changes to Clojure in Version 1.10

1 Compatibility and Dependencies

1.1 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 πŸŸ₯
  • CLJ-2414
    Regression in reflectively finding default methods πŸŸ₯

1.2 Dependencies

Updated dependencies:

  • spec.alpha dependency to 0.2.176 - changes 🟨
  • core.specs.alpha dependency to 0.2.44 - changes 🟨

2 Features and major changes

2.1 Error messages

Clojure errors can occur in several distinct "phases" - reading source, macroexpansion, compilation, execution, and result printing. Clojure (and the REPL) now identify these phases in the exception and 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 following (optional) keys:

  • :clojure.error/phase - phase (:read-source, :macro-syntax-check, :macroexpansion, :compile-syntax-check, :compilation, :execution, :read-eval-result, :print-eval-result)
  • :clojure.error/source - source file
  • :clojure.error/line - line in source file
  • :clojure.error/column - column of line in source file
  • :clojure.error/symbol - symbol being macroexpanded or compiled
  • :clojure.error/class - cause exception class symbol
  • :clojure.error/cause - cause exception message
  • :clojure.error/spec - explain-data for spec errors

clojure.main also contains two new functions: ex-triage and ex-str that can be used by external tools to mimic some or all of the Clojure repl reporting. ex-triage takes the output of Throwable->map and produces a concise analysis of the error phase, cause, etc (same keys as above). ex-str takes that analysis data and produces a message to print at the repl.

  • CLJ-2373 🟩
    Detect phase and overhaul exception message and printing
  • CLJ-2415 🟩
    Error cause should always be on 2nd line of error message
  • CLJ-2420 🟩
    Refinement of error phases, ex-triage, execution error line reporting
  • CLJ-2427 🟨
    CompilerException.toString() can throw if making message during initialization
  • CLJ-2430 🟨
    Elevate phase in throwable data and conveyance for prepl
  • CLJ-2435 🟨
    Include root cause class name in compilation and macroexpansion error phases
  • CLJ-2438 🟨
    Demunge source symbol in execution error messages

2.2 Protocol extension by metadata

defprotocol has a new option :extend-via-metadata. When :extend-via-metadata is true, values can extend protocols by adding metadata where keys are fully-qualified protocol function symbols and values are function implementations. Protocol implementations are checked first for direct definitions (defrecord, deftype, reify), then metadata definitions, then external extensions (extend, extend-type, extend-protocol).

  • Protocol extension by metadata 🟩

2.3 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.

  • tap 🟩

2.4 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.

  • Read string capture mode 🟩

2.5 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.

  • prepl 🟩

2.6 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.

  • CLJ-2429 🟩
    Datafy JavaReflector

2.6 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 🟨

The following function has been added, extending resolve:

  • requiring-resolve - resolve or, if needed, require symbol's namespace, then resolve 🟨
  • serialized-require - like require but for use in asynchronous load uses 🟨

3 Enhancements

3.1 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 🟨

3.2 Documentation

  • CLJ-2044 🟨
    clojure.instant - add arglist meta for functions
  • CLJ-2257 πŸŸ₯
    proxy - fix typo
    There is no proxy in Clojerl.
  • CLJ-2332 🟨
    remove-tap - fix repetition
  • CLJ-2122 🟩
    flatten - describe result as lazy

3.3 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

3.4 Other enhancements

  • symbol can now take a var or a keyword argument 🟨
  • CLJ-1209 🟨
    Print ex-data in clojure.test error reports
  • CLJ-2163 🟨
    Add test for var serialization
  • CLJ-2417 🟨
    sort and sort-by should retain meta

4 Fixes

4.1 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

4.2 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
    Clojerl has no unchecked math.

4.3 Other

  • CLJ-1403 🟨
    ns-resolve might throw ClassNotFoundException but should return nil
  • CLJ-2407 🟨
    Fix bugs in Clojure unit tests
  • CLJ-1079 🟨
    In reader, don't ignore explicit :line :col meta