~remexre/nrutil

5e83ff3c4b683429242c1a2c98d85ba59b2b6a37 — Nathan Ringo 5 months ago 976e1ea
Change def-data-class to use &key args in the constructor.
1 files changed, 5 insertions(+), 4 deletions(-)

M main.lisp
M main.lisp => main.lisp +5 -4
@@ 156,8 156,9 @@
                            :type ,field-type)
                          (cddr field))))
      (collect spec into class-fields)
      (collect field-name into field-names)
      (collect field-type into field-types)
      (collect (cons field-name (and (getf (cddr field) :initform)
                                     (list (getf (cddr field) :initform)))) into ctor-args)
      (collect (list kwd field-type) into ctor-type-args)
      (appending (list kwd field-name) into field-kwargs)
      (appending (list kwd `(list 'quote (,reader-name object)))
        into print-object-args)


@@ 166,8 167,8 @@
                    (defclass ,name ,(append superclasses (list 'data-class))
                      ,class-fields
                      ,@class-options)
                    (declaim (ftype (function ,field-types (values ,name &optional)) ,name))
                    (defun ,name ,field-names
                    (declaim (ftype (function (&key ,@ctor-type-args) (values ,name &optional)) ,name))
                    (defun ,name (&key ,@ctor-args)
                      (make-instance ',name ,@field-kwargs))))))))

(defvar *genint-counter* 0)