As some of you might know, I've been working contiuously on my various
tools.* contrib libraries for the past months and I've recently added
tools.analyzer.js to the list of contrib libraries I maintain.
Since I don't blog/tweet much about those libraries, I thought I'd write
a report to let the community aware of the status of those libraries.

## tools.analyzer https://github.com/clojure/tools.analyzer

tools.analyzer is a host-agnostic pluggable analyzer and collection of
passes producing an AST in clojure data structures for clojure and
other languages in the clojure language family, like clojurescript.

The current release is 0.5.1, here's a list of notable changes that have
made in in the last few months:

* The analyzer now uses different environments for lexical state (like
  the locals map) and for global state (like namespaces mappings); the
  former is just a regular map passed to an analyze call, the latter is
  a dynamic var holding an atom and lives in the tools.analyzer.env
  namespace along with functions to setup/manipulate it.

* The metadata elision mechanism has been vastly improved, allowing to
  specify different keys to elide based on the node :op, aswell as based
  on a predicate rather than simple key matching.

* The env context now partecipates in a keyword hierarchy, the default
  contexts are :ctx/statement, :ctx/return and :ctx/expr and other
  contexts can be derived from those, as an example tools.analyzer
  utilizes :ctx.invoke/target and :ctx.invoke/params for nodes in invoke
  position.

* Dispatch on clojure expressions types has been opened with the
  -analyze-form multimethod, allowing to provide custom evaluation
  strategies for custom types (this was needed for tools.analyzer.js
  because of clojurescript's #js syntax)

* Documentation has been vastly improved with docstrings for every
  public function and pass, and the addition of an official AST
  quickref http://clojure.github.io/tools.analyzer/spec/quickref.html

For a complete list of changes, refer to the CHANGELOG:
https://github.com/clojure/tools.analyzer/blob/master/CHANGELOG.md

For more informations and examples, refer to the README:
https://github.com/clojure/tools.analyzer/blob/master/README.md

## tools.analyzer.jvm https://github.com/clojure/tools.analyzer.jvm

tools.analyzer.jvm is a jvm-specific tools.analyzer extension,
collection of passes and useful functions to deal with analysis of
clojure on the JVM code.

The current release is 0.5.2, here's a list of notable changes that have
made in the last few months:

* Added an analyze-ns function that returns a vector of AST nodes for
  every top-level form in that namespace; evaluates each form.

* Added a configurable handler for wrong tags: while Clojure is
  permissive of type hints that don't resolve to a Class which it
  simply ignores in most cases, tools.analyzer.jvm's default behaviour
  has always been to throw an exception in those cases. This has been a
  longstanding issue for tools like eastwood that want to simply emit a
  warning on those cases rather than stopping analysis and error out.
  With the addition of this handlers, users can now control what happens
  when t.a.jvm hits a tag that can't be resolved to a Class.

* Added optional Var-level tag inference

* Improved analyze+eval to attach the result of the evaluation of the
  node to the AST, wrapping potential exceptions at evaluation time in
  an ExceptionThrown record.

* Documentation has been vastly improved with docstrings for every
  public function and pass, and the addition of an official AST
  quickref http://clojure.github.io/tools.analyzer.jvm/spec/quickref.html

For a complete list of changes, refer to the CHANGELOG:
https://github.com/clojure/tools.analyzer.jvm/blob/master/CHANGELOG.md

For more informations and examples, refer to the README:
https://github.com/clojure/tools.analyzer.jvm/blob/master/README.md

## tools.analyzer.js https://github.com/clojure/tools.analyzer.js

tools.analyzer.js is a js-specific tools.analyzer extension, collection
of passes and useful functions to deal with analysis of clojurescript
code.

The current release is 0.1.0-beta4.

The produced AST is not compatible with the one produced by
cljs.analyzer even though they are similar as the cljs analyzer heavily
influenced the AST format of tools.analyzer.
tools.analyzer.js has several advantages over cljs.analyzer:

* Heavily modular implementation, thanks to the :children-walking based
  multi-pass design.

* Unified AST format and analyzer interface between clj and cljs code
  analyzers, this will allow library authors to write passes that can be
  shared between different analyzers and write code that will work for
  both clj and cljs with only minimal changes.

* Caching of the namespace env: because of its multi-pass nature, t.a.js
  is a bit slower than the (mostly) single-pass cljs.analyzer, to
  compensate for this, t.a.js offers a mechanism of storing on disk &
  reloading the namespace map and bundles the namespace map of cljs.core
  so that it's not necessary to analyze it each time at startup like
  with cljs.analyzer.

For a complete list of changes, refer to the CHANGELOG:
https://github.com/clojure/tools.analyzer.js/blob/master/CHANGELOG.md

For more informations and examples, refer to the README:
https://github.com/clojure/tools.analyzer.js/blob/master/README.md

## tools.emitter.jvm https://github.com/clojure/tools.analyzer.jvm

tools.emitter.jvm is a bytecode compiler for clojure, that uses
tools.analyzer.jvm as its frontend.

The current release is 0.1.0-beta5, currently the compiler has been
tested and is working on clojure.core and most clojure namespaces from
the standard library and the contrib libraries, in the last few months
several enhancements to how the compiler works internally and regarding
the emitted bytecode have been committed, for example:

* A complete refactor of the internal emit and emit-class functions to
  be more functional and stateless, thanks to Reid McKenzie.

* The emitted bytecode clears the "this" local before tail calls, see
  http://dev.clojure.org/jira/browse/CLJ-1250 for the issue this solves.

* The emitted code hoists try/loop bodies in a different method rather
  than wrappping them in a fn*, see
  http://dev.clojure.org/jira/browse/CLJ-701 for the issue this solves;
  the implementation in t.e.jvm is more general than the one implemented
  for the clojure compiler.

* Improved the load and eval functions to take an optional options map
  with options that can be propagated from load to eval, and from eval
  to the analyzer.

For a complete list of changes, refer to the CHANGELOG:
https://github.com/clojure/tools.emitter.jvm/blob/master/CHANGELOG.md

For more informations and examples, refer to the README:
https://github.com/clojure/tools.emitter.jvm/blob/master/README.md


If you've made it this far and have any question or comment,
please let me know and I'll be more than happy to reply.

Nicola

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to