[armedbear-devel] CLOS / D-M-C tests failure DMC-TEST-MC.1 help requested

Rudolf Schlatte rudi at constantly.at
Tue Aug 7 18:56:10 UTC 2012

On Aug 7, 2012, at 20:41, Erik Huelsmann <ehuels at gmail.com> wrote:

> Ok. I figured out what's happening, at least inside SLIME, but I assume the same happens for the compiler. At least, if we can  fix this happening in SLIME, we can probably fix it for the compiler as well.
> So, just to show the code that's failing to be correctly compiled:
> Form 1:
> (define-method-combination dmc-test-args-with-optional.4 ()
>   ((methods ()))
>   (:arguments &optional (a :default sup-p))
>   `(progn ,@(mapcar (lambda (method) `(call-method ,method))
>                     methods)
>           (values ,a ,sup-p)))
> Form 2:
> (defgeneric dmc-test-args-with-optional.4a (x &optional b)
>   (:method-combination dmc-test-args-with-optional.4)
>   (:method (x &optional b) (progn x b)))
> My compilation steps are to go into Form 1 and hit C-c C-c. Then do the same with Form 2.
> Every time when I do that, the method combination of the generic function comes out with #<METHOD-COMBINATION STANDARD>. Which is clearly wrong.
> What happens is that the second form expands into:
>                            :LAMBDA-LIST
>                            '(X &OPTIONAL B)
>                            :METHOD-COMBINATION
>                            '(DMC-TEST-ARGS-WITH-OPTIONAL.4))
>                         (X &OPTIONAL B)
>                         (PROGN X B))
> Because the macro expander continues to expand the forms before compiling them, it'll expand the DEFMETHOD above. When the DEFMETHOD gets expanded however, it's expansion is dependent on the existence of the generic function. However, since the form as a whole hasn't been interpreted yet, there *is* no generic function: after all, that's being created in the first form of the PROG1.
> Something similar probably happens during compilation.
> I'm now wondering what the next step should be to resolve this situation...
> Ah. Going back 10 months and looking at the DEFMETHOD macro there, I see now what the difference is between then and now: back then we didn't depend on the GF existing during the macro expansion. Now we do. Can we generate a different macroexpansion which defers the GF-being-defined requirement to evaluation time?

Cute.  I think we can beef up %defgeneric to accept a list of method descriptions and the macro environment (for make-method-lambda) and call ensure-method inside %defgeneric, after creating the generic function.  I can have a look at that.


More information about the armedbear-devel mailing list