Creating records using macro in Clojure -


i want define vector values want use in record , pass vector macro creates record.

(def keys ['data1 'data2 'data3])  (defmacro make-record  [n v & body] `(defrecord ~n ~v ~@body)) (make-record vud vud-keys) (macroexpand-1 '(make-record type keys)) -> (defrecord type keys) 

what want is:

(macroexpand-1 '(make-record type keys)) -> (defrecord type ['data1 'data2 'data3]) 

it looks need evaluate arguments during macroexpansion. eval does.

(def keys '[data1 data2 data3]) (defmacro make-record [name keys]   `(defrecord ~name ~(eval keys))) 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -