[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GOOPS: calling next-method with different arguments.

From: Panicz Maciej Godek
Subject: Re: GOOPS: calling next-method with different arguments.
Date: Fri, 19 Apr 2013 10:54:31 +0200

2013/4/19 Tobias Brandt <address@hidden>
I posed the following question regarding constructors in Lisp/CLOS on stackoverflow:

The accepted answer uses the ability of CLOS to modifiy the arguments passed to CALL-NEXT-METHOD.

I know it's (currently) not possible to change the method arguments when calling next-method in GOOPS. How would you solve that problem (if possible)?

GOOPS offers a procedure `generic-function-methods`, which does what it says, i.e. returns all the methods of a generic function.
It can be called on `initialize` generic as well, returning the list of all defined initialize methods.
The we need to get those methods that apply to the superclass of our class. We get those classes using `class-direct-supers`, and we can find out whether a method applies to a certain class using `method-specializers` procedure.
The `method-specializers` takes a method and returns a list (possibly improper) of classes that correspond to the types of a considered method's arguments.
Therefore, we can take a list of all initializers, such that their first specializer belongs to one of our supers.
We can then use `apply-method` with our current object and whatever argument list we like, and this is actually what you asked for.

I think that this should work, although I haven't tried that myself. You can try that and let us know if it works.

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]