Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6323541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:32:17+00:00 2026-05-24T16:32:17+00:00

In Common-Lisp CLOS Is it possible to dynamically add one more super class in

  • 0

In Common-Lisp CLOS

Is it possible to dynamically add one more super class
in existing class.

Update:

I wanted to defined defassoc kind of macro that will associated some behaviour
with method/function using same argument

e.g.

(defassoc (gname (s (g group)))
    ((name1 (name ((corresponding-task task g) s)))
     (record1 (record ((corresponding-task task g) s))))
  (let ((n name1)
        (r record1))
    (if (and name1 record1)
        (display name1 record1)
        (call-next-method))))

expand to

(symbol-macrolet ((name1 (name ((corresponding-task task g) s)))
                  (record1 (record ((corresponding-task task g) s))))
  (defmethod gname :after (s (g group))
            (let ((n name1) (r record1))
              (if (and name1 record1)
                  (display name1 record1)
                  (call-next-method)))))

Here it is ensuring when ever (gname (s (g group)) is call
here should be call for corresponding task to group

(name ((corresponding-task task g) s)
(record ((corresponding-task task g) s)

I used this macro

(defmacro defassoc ((main-method main-method-lambda-list)
                    funspec-list &body body)
  `(symbol-macrolet ,(mapcar (lambda (fspec)
                               (destructuring-bind (name f) fspec
                                 (list name f)))
                             funspec-list)
     (defmethod
       ,main-method ,mod ,main-method-lambda-list
       ,@(if body
             body
             `(if (and
                   ,@(mapcar (lambda (e)
                               (car e))
                             funspec-list))
                  (call-next-method)))))

But problem is that it will overwrite the

(defmethod gname :after (s (g group))
      ...)

(If it has any, I can verify it if it has one or not,)

But I want it to work for any object whether it has that method to overwrite or not

So basically it should be needed to change in code for any thing in that classes and methods.

So one way I decided that to dynamically add parent class to define this method on it.

Other way could be defadvide or fwrapper but it is not present in SBCL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:32:18+00:00Added an answer on May 24, 2026 at 4:32 pm

    Yes, it’s possible. The easiest way would be to simply redefine the class. You do that by issuing another call to DEFCLASS. If you want to do more complicated things, you have to resort to the MOP (MetaObject Protocol). Essentially everything you’d ever want to do is possible using the MOP, but I would need more detailed information as to what it is you’re trying to do in order to explain it further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With common lisp and I am assuming the introspection properties. How can I add
Does any Common Lisp (builtin) function return more than 2 values? I know many
If you want to make CLOS objects in common lisp printable (print readably), how
One thing I really miss when writing Common Lisp code is access to Python
In Common Lisp, how can I override the default string representation of a CLOS
In Common Lisp, if I wanted to check whether a list was not null,
I have a class in Common Lisp: (defclass my-cool-class() ((variable1 :initarg :variable1 :accessor variable1
After reading Practical Common Lisp I finally understood what the big deal about macros
Are there any Common Lisp implementations for .Net?
im reading Practical common Lisp as a result of another question . I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.