mozilla/sweet.js — pull request #350 by natefaubion (2014-06-22 01:03:51+00:00)
Title: Macroclass cont'd

This PR refines the experimental `macroclass` feature we released with 0.6.0. The syntax has changed slightly, and auxillary bindings are a bit more robust.

You declare `pattern`s like before, but instead of being rules themselves, `pattern`s contain a `rule` declaration along with any auxillary `with` bindings. I renamed `where` to `with` to mirror `withSyntax`. `with` bindings support syntax quotes with `#{}` but can also use syntax constructors like `makeValue` et al. Additionally, `pattern`s with only a `rule` declaration can be collapsed into a single `rule` to mirror identity rules.

Here is an example implementation of clojure-like protocols using `macroclass`es: https://gist.github.com/natefaubion/bd7addb60a888c1ec759