2010-06-03 6 views

Antwort

14
 

; given a function name, its args and body, create 2 versions: 
; ie (double-it foo []) should create 2 functions: foo and foo* 
(defmacro double-it     
    [fname args & body]   
    `(do (defn ~fname ~args [email protected]) 
     (defn ~(symbol (str fname "*")) ~args [email protected]))) 

(double-it afunc [str] (println str)) 

(afunc* "asd") 
(afunc "asd") 
 

Keine Notwendigkeit, sie separat zu zitieren.

Verwandte Themen