[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: Sat, 20 Apr 2013 00:58:04 +0200

I've been trying to make some deeper inquiry. It turns out that the case is not as simple as I thought.
I came up with the following function
(use-modules (oop goops) (ice-9 match) (srfi srfi-1))

(define (parent-methods method class)
  (let* ((supers (class-direct-supers class))
         (super? (lambda(c)(find (lambda(s)(eq? c s)) supers))))
    (filter-map (match-lambda((method (? super? super) args ...) method) (else #f))
(map (lambda(m)(cons m (method-specializers m)))
                     (generic-function-methods method)))))

it works more or less as expected, at least for initializers (because it is defined in such way that it only looks at the method's first argument) -- it does return a list of parents' initializers.

The problem appears if a parent's initializer contains (next-method) invocation. Otherwise (if there's no call to (next-method)) the method contains a procedure in its 'procedure' slot, which can be accessed using `method-procedure`, and then called or applied in a regular manner. 
However, if there is a call to (next-method) in a macro, the `method-procedure` called on such method returns #f. I think the idea is that methods are meant to be called from the context of `apply-generic` and next-method is a continuation, but I haven't figured out how it works exactly.
Anyway, the thing isn't as simple as I thought and perhaps someone else could try another approach.

Sorry for causing confusion!

reply via email to

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