I just found a quick-n-dirty way to replace mac2 (http://arclanguage.org/item?id=17233) with pattern-matching support in def and mac: https://github.com/akkartik/wart/commit/5e9d3fddb3#diff-2 Try it out: $ git clone http://github.com/akkartik/wart
$ cd wart
$ git checkout 5e9d3fddb3
$ ./wart
ready! type in an expression, then hit enter twice. ctrl-d exits.
(def (foo n) nil)
(def (foo 'a) 0)
(foo 3)
=> nil
(foo a)
=> 0
Prominent limitations:a) No support for constants. (foo '0) ends up code generating to: ..
if (0 = '0)
..
and so will always succeed.b) Only supported in def without :case. I'm basically not sure whether to support selective quoting or pattern matching. Suggestions? |