Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.match by

The following explodes because of the presence of {{recur}}:

`
(defn rec [expr]
(match expr

     [:global] 'GLOBAL
     [:constant x] x
     [:variable x] x
     [:lazy-variable x] `(deref ~x)
     [:if test if-true if-false] `(if ~(rec test)
                                    ~(rec if-true)
                                    ~(rec if-false))
     [:delist list index] `(get ~(rec list) ~(rec index))
     [:depair pair key] `(get ~(rec pair) ~(match key :first 0 :second 1))
     [:list elements] (map rec elements)
     [:fold-recur index-arg list-sym] `(recur (+ 1 ~index-arg) (rest ~list-sym))
     [:zip left right] `(map vector ~(rec left) ~(rec right))
     [:filter list arg body] `(filter (fn [~arg] ~(rec body) ~(rec list)))
     [:len list] `(count ~(rec list))
     [:pair first second] [(rec first) (rec second)]
     [:block arg body] `(fn [~arg] ~(rec body))
     [:app f arg] `(~(rec f) ~(rec arg))
     [:query e annotations] `(QUERY ~(rec e) ~annotations)
     [:lookup key] `(LOOKUP ~key)
     [:let name value expr] `(let [~name ~value] expr)
     ; ... about 15 more
     ))

`

3 Answers

0 votes
by

Comment made by: jneen

A hacky workaround is to interpolate the {{'recur}} symbol from an outer scope.

`
(def recur-sym 'recur)

(match expr
... (~recur-sym ...)) ``

0 votes
by

Comment made by: dnolen

Now that tools.analyzer exists it won't be difficult to solve this properly.

0 votes
by
Reference: https://clojure.atlassian.net/browse/MATCH-95 (reported by dnolen)
...