Movatterモバイル変換


[0]ホーム

URL:


ClojureScript
1.10.439 Release

1.10.439 Release

02 November 2018
ClojureScript Team

Noteworthy Changes

Closure Compiler has been upgraded to v20180805.

The:npm-depscompiler option now defaults tofalse. Previously,:npm-deps defaulted totrue.

Improved Compiler Performance

The compiler is now much faster when compared with the 1.10.339 release for both regular buildsand when:parallel-build is set totrue.

Warnings on Private Var Use

ClojureScript will now warn on private var use.

Let’s say you have a function intended for private use in a namespace:

(ns foo.core)(defn- some-impl [x]  (inc x))

and you inadvertently use it from some other namespace, as in

(ns bar.core (:require [foo.core]))(foo.core/some-impl 3)

The compiler will now emit a helpful diagnostic:

WARNING: var: foo.core/some-impl is not public

This is only a warning; the ClojureScript compiler continues to allow private var use, but now emits a new analysis warning, controllable via:private-var-access.

If var indirection is used instead, no warning will be emitted:

(#'foo.core/some-impl 3)

Function Return Type Inference

ClojureScript now infers function return types, propagating this informationto call sites.

Consider these predicates:

(defn finite? [x]  (not (infinite? x)))(defn big? [x]  (and (pos? x)       (finite? x)))

Previously, code like the following

(if (big? 11)  "hi"  "bye")

would emit defensive JavaScript that coerces the return value ofbig?to a Boolean by usingcljs.core.truth_:

(cljs.core.truth_(cljs.user.big_QMARK_.call(null,(11)))?"hi":"bye")

Now, the compiler instead infers thatfinite? always returns a Booleanvalue, and therefore so doesbig?, and emits more efficient code:

((cljs.user.big_QMARK_.call(null,(11)))?"hi":"bye")

With inference like this, it is no longer necessary to manually add a^booleantype hint to a predicate used in performance-critical code, so long asthe return value can be infered from the predicate function body.

In general, any inferred types will automatically flow fromfunction bodies outward, such as an inferred numeric type in the followingexample:

(defn foo [x]  (+ x 3))

Iffoo is used in a context where types are checked, as in

(+ (foo 1) "a")

you will now see a warning that properly reflects the type:

WARNING: cljs.core/+, all arguments must be numbers, got [number string] instead

Previously, without a type hint onfoo, the compiler would produce awarning that indicates a type ofany instead ofnumber.

Graal.JS REPL Environment

ClojureScript now ships with a Graal.JS REPL environment. This is a new Java-based REPLenvironment which is similar to the existing Nashorn REPL environment, but instead usesthe newGraal.JS JavaScript engine that ships as part of GraalVM.

The Graal.JS REPL environment automatically configures the Graal.JS engine to allowPolyglot calls to other languages that may be installed.

If you have the GraalVM version of Java on your path, to use this new REPL environmentwithcljs.main, simply specify--repl-env graaljs:

$ clj -M --main cljs.main --repl-env graaljs --replClojureScript 1.10.439cljs.user=> (.eval js/Polyglot "R" "sum(1:100)")5050cljs.user=> (.eval js/Polyglot "ruby" "(1..100).reduce(:+)")5050

In addition to Polyglot support, the Graal.JS engine is much faster than Nashorn,approaching the performance of the other leading JavaScript engines, especially whenwarmed up and the JVM has had an opportunity to optimize hotspots.

Since GraalVM hasn’t yet been released and things could still change, this new REPL environmentshould be considered beta. We encourage you to give it a try!

Updates to Spec

This release includes many updates to Spec, bringing changes and fixes that have been made to theClojure implementation of Spec to ClojureScript.

Updates to AST Representation

The internal AST representation has been updated to matchtools.analyzer. This will simplify thingsfor tooling that works with the AST generated by ClojureScript.

Change List

For a complete list of updates in ClojureScript 1.10.439 seeChanges.

Contributors

Thanks to all of the community members who contributed to ClojureScript 1.10.439:

  • Ambrose Bonnaire-Sergeant

  • Erik Assum

  • Eugene Kostenko

  • Henry Widd

  • Jordan Biserkov

  • Juho Teperi

  • Mike Fikes

  • Oliver Eidel

  • Ray McDermott

  • Thomas Spellman

Grant Support

Thanks toClojurists Together and itssupporting members for funding a significant amount of work that wentinto this release!

For details see

Documentation
OverviewReferenceToolsGuides
Community
ResourcesContributingCompaniesEvents
Code
API CheatsheetSourceChangelog
ETC
ClojureTV
Legal
LicensePrivacy Policy
 
Copyright Rich Hickey |Privacy Policy
Published 2025-03-31
Site design by Tom Hickey

[8]ページ先頭

©2009-2025 Movatter.jp