Hi, I'm working on some code that use records. At the moment record_info is
missing. To solve that I tried to create a macro with the goal of only
making me declare the record in one place.
How to do this in a better way? Some one may have already tried this.
---
(eval-when-compile
(defun def_record_funs ()
(list '(name 0) '(source 0))) ; <-- declared in one place.
(defun name_only (x)
(if (== x '())
'()
(cons (hd (hd x))
(name_only (tl x)))))
)
(defmacro defrecord_funs ()
`(defrecord funs
,@(def_record_funs)))
(defrecord_funs)
(defmacro record_info_fields_funs ()
`',(list_to_tuple
(name_only
(def_record_funs)))
---
Now I can create a mnesia table with:
---
(: mnesia create_table 'funs
(list (tuple 'attributes
(record_info_fields_funs)))))
---