Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce define-dao-class macro? #341

Closed
kilianmh opened this issue Apr 9, 2024 · 2 comments · Fixed by #345
Closed

Introduce define-dao-class macro? #341

kilianmh opened this issue Apr 9, 2024 · 2 comments · Fixed by #345

Comments

@kilianmh
Copy link
Contributor

kilianmh commented Apr 9, 2024

For a project I defined a convenience macro define-dao-class because we basically always want to define the :col-type slot and don't want to forget the metaclass. I was thinking it might be a nice addition.

  1. The second slot is used as value for :col-type if its not a keyword.
  2. Automatically add the slot (:metaclass dao-class)
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defun expand-slot (rest)
    (let ((second
	    (second rest)))
      (if (keywordp second)
	  `(,(first rest)
	    ,@(cdr rest))
	  `(,(first rest)
	    :col-type ,second
	    ,@(cddr rest))))))

(defmacro define-dao-class (name direct-superclasses direct-slots &rest options)
  `(defclass ,name ,direct-superclasses
     (,@(mapcar #'expand-slot direct-slots))
     ,@(append options
	'((:metaclass dao-class)))))

What do you think?

@sabracrolleton
Copy link
Collaborator

I will consider it if you think about appropriate tests.

@sabracrolleton
Copy link
Collaborator

I probably will not get to it until late next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants