Hi!<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">> 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.<br>
><br>
> So, just to show the code that's failing to be correctly compiled:<br>
><br>
> Form 1:<br>
> (define-method-combination dmc-test-args-with-optional.4 ()<br>
> ((methods ()))<br>
> (:arguments &optional (a :default sup-p))<br>
> `(progn ,@(mapcar (lambda (method) `(call-method ,method))<br>
> methods)<br>
> (values ,a ,sup-p)))<br>
><br>
> Form 2:<br>
> (defgeneric dmc-test-args-with-optional.4a (x &optional b)<br>
> (:method-combination dmc-test-args-with-optional.4)<br>
> (:method (x &optional b) (progn x b)))<br>
><br>
><br>
> My compilation steps are to go into Form 1 and hit C-c C-c. Then do the same with Form 2.<br>
><br>
> Every time when I do that, the method combination of the generic function comes out with #<METHOD-COMBINATION STANDARD>. Which is clearly wrong.<br>
><br>
> What happens is that the second form expands into:<br>
><br>
> (PROG1 (SYSTEM:%DEFGENERIC 'DMC-TEST-ARGS-WITH-OPTIONAL.4A<br>
> :LAMBDA-LIST<br>
> '(X &OPTIONAL B)<br>
> :METHOD-COMBINATION<br>
> '(DMC-TEST-ARGS-WITH-OPTIONAL.4))<br>
> (PUSH (DEFMETHOD DMC-TEST-ARGS-WITH-OPTIONAL.4A<br>
> (X &OPTIONAL B)<br>
> (PROGN X B))<br>
> (SYSTEM:GENERIC-FUNCTION-INITIAL-METHODS (FDEFINITION 'DMC-TEST-ARGS-WITH-OPTIONAL.4A))))<br>
><br>
> 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.<br>
><br>
> Something similar probably happens during compilation.<br><br>
</div></div>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.</blockquote>
<div><br></div><div>Well, I hope you don't mind, but I quickly looked at the problem last week myself as well. From all the scenario's that I could come up with the simplest (and most unsatisfying in terms of "everything is delayed to load time and I want more at compile time") is what I tried (see attached patch).</div>
<div><br></div><div>This patch seems to solve the "compile in memory" issue, but for some reason, it doesn't seem to solve the compilation problem.</div><div><br></div><div>Also, note that the patch is incomplete, because the forms - before being stored for load-time evaluation - should at least be macro-expanded to expand macrolet and symbol-macrolet in the body.</div>
<div><br></div><div>Hopefully it's something to give you a head start in your analysis. (I'm not going to commit this, unless it's by accident.)</div><div><br></div><div><br></div><div>Bye,</div><div><br></div>
<div>Erik.</div></div>