;;;###mh-autoload
(defmacro mh-defstruct (name-spec &rest fields)
+ ;; FIXME: Use `cl-defstruct' instead: shouldn't emit warnings any
+ ;; more nor depend on run-time CL functions.
"Replacement for `defstruct' from the \"cl\" package.
The `defstruct' in the \"cl\" library produces compiler warnings,
and generates code that uses functions present in \"cl\" at
(constructor (or (and (consp name-spec)
(cadr (assoc :constructor (cdr name-spec))))
(intern (format "make-%s" struct-name))))
- (field-names (mapcar #'(lambda (x) (if (atom x) x (car x))) fields))
- (field-init-forms (mapcar #'(lambda (x) (and (consp x) (cadr x)))
- fields))
+ (fields (mapcar (lambda (x)
+ (if (atom x)
+ (list x nil)
+ (list (car x) (cadr x))))
+ fields))
+ (field-names (mapcar #'car fields))
(struct (gensym "S"))
(x (gensym "X"))
(y (gensym "Y")))
`(progn
- (defun* ,constructor (&key ,@(mapcar* #'(lambda (x y) (list x y))
- field-names field-init-forms))
+ (defun* ,constructor (&key ,@fields)
(list (quote ,struct-name) ,@field-names))
(defun ,predicate (arg)
(and (consp arg) (eq (car arg) (quote ,struct-name))))