• (deftemplate name params & forms)
Define a macro that expands into forms after replacing the
symbols in params (a vector) by the corresponding parameters
given in the macro call.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/macro_utils.clj:236 top

(defmacro deftemplate
  "Define a macro that expands into forms after replacing the
   symbols in params (a vector) by the corresponding parameters
   given in the macro call."
  [name params & forms]
  (let [param-map (for [p params] (list (list 'quote p) (gensym)))
	template-params (vec (map second param-map))
	param-map (vec (apply concat param-map))
	expansion (list 'list (list 'quote `symbol-macrolet) param-map
			(list 'quote (cons 'do forms)))]
    `(defmacro ~name ~template-params ~expansion)))
Vars in clojure.contrib.macro-utils/deftemplate: defmacro let name concat list seq
Used in 0 other vars

Comments top

No comments for deftemplate. Log in to add a comment.