Hi Maxime and Panicz, Maxime: I guess you meant <generic> rather than <method>, which is not applicable.
Panicz: Well, applicable objects were never added to the official API in GOOPS. When I left Guile development, there were still issues around the meta object protocol to sort out. As things stand right now, it is possible to define a class <applicable-object> like this: (define-class <applicable-object> (<applicable-struct>) #:metaclass <applicable-struct-class>) All classes that inherit from <applicable-object> will now have a slot 'procedure which is invoked if the object is applied. So, you can do: (define-class <accumulator> (<applicable-object>) (sum #:init-value 0 #:accessor sum)) (define-method (initialize (obj <accumulator>) initargs) (next-method) (slot-set! obj 'procedure (lambda (n) (set! (sum obj) (+ n (sum obj))) (sum obj)))) (define a (make <accumulator>)) (a 2) -> 2 (a 3) -> 5 There's a caveat, however (and one of the reasons why this is not documented): The procedure slot needs to be the first slot of the object for the current application mechanism to work. In theory, something like this would be the solution you are searching for: (define-class <applicable-class> (<applicable-object> <class>)) (define-method (initialize (class <applicable-class>) initargs) (next-method) (slot-set! class 'procedure (lambda initargs (apply make class initargs)))) However, this won't work since classes also have special wishes about the first slot and will make sure that 'procedure won't be the first slot. This should of course be solved in a way that the user doesn't need to think about all magic. The GOOPS implementation has changed quite a lot since I worked on it, so it would take me some work to realize what could be done about it, but I could give it a try when I get time. Of course everybody else is welcome to come with proposals. Best regards, Mikael On Fri, May 23, 2025 at 7:51 PM Maxime Devos via General Guile related discussions <guile-user@gnu.org> wrote: > GOOPS methods are instances of <method>, and methods are applicable, so > yes. > > For <method>, this is done with (undocumented) applicable structs (see: > GOOPs implementation). > > But, no high-level GOOPs support is available for repeating the same for > other classes. >