Based on the example provide in the practical common lisp reference, I define a macro to create a class as followed.
(defmacro define-class (class-name class-slot) `(defclass ,class-name () ,(mapcar #'slot->defclass-slot class-slot)))) The function slot->declass-slot take a single argument and generate a standard line describing a slot in a class. The code is the following:
(defun slot->defclass-slot (spec) `(,spec :initarg ,(as-keyword spec) :accessor ,spec :initform 0)) For example,
(slot->defclass-slot 'nom) (NOM :INITARG :NOM :ACCESSOR NOM :INITFORM 0) All this work fine, when I create a class 'model' as follow:
(define-class model (nom id)) But suppose that I define a parameter instead.
(defparameter *test* '(nom id)) (define-class model *test*) Then, the code end-up in an error:
The value *TEST* is not of type LIST. What is wrong?