What makes me suspicious is the output of (describe (make-instance 'funcallable-standard-object)) vs (describe (make-instance 'standard-generic-function)) .
There's a layout called layoutFuncallableStandardClass, defined in StandardClass.java, which has NAME as first slot, but that's for class objects with metaclass funcallable-standard-class, not for instances of these classes. I'll think a bit in the next days and try to either resolve my doubts or come up with another fix for the problem. Maybe I'm simply confused; wouldn't be the first time. :)
Rudi
On Apr 2, 2013, at 19:52, Erik Huelsmann ehuels@gmail.com wrote:
Hi Rudi,
Basically the expectation we violated was the fact that %set-lambda-name didn't want to take a funcallable instance as its function argument. The commit changed that and used the first slot of the funcallable instance class layout (called NAME) to store the name. I guess we forget to finalize the class somewhere, so the spots don't appear?
Bye,
Erik.
sent from my phone
On Apr 2, 2013 7:32 PM, "Rudolf Schlatte" rudi@constantly.at wrote: Hi,
I suspect that the changes in commit r14452 only work by accident.
The definions of SLOT_INDEX_NAME in FuncallableStandardClass vs FuncallableStandardObject are no problem, since the latter simply isn't used anywhere. But the new methods getName() and setName() assume that a) the FuncallableStandardObject instance has at least one slot, and b) that slot holds a name. Since (class-slots (find-class 'funcallable-standard-object)) returns NIL, these assumptions hold only when the objects are in fact generic functions.
Amusingly, (function-lambda-expression (make-instance 'funcallable-standard-object)) runs into the type error on line 2666 of Primitives.lisp ("The value #<FUNCALLABLE-STANDARD-OBJECT {665C5A83}> is not of type FUNCTION.") even though (typep (make-instance 'funcallable-standard-object) 'function) => T so I can't trigger the array-out-of-bounds error right now.
Could I have a recipe for triggering the bug? I'd like to see how cl-cont uses funcallable-standard-objects, and what expectations we violate. I believe I can fix this properly.
Cheers,
Rudi
Hi Rudi,
On Tue, Apr 2, 2013 at 8:08 PM, Rudolf Schlatte rudi@constantly.at wrote:
What makes me suspicious is the output of (describe (make-instance 'funcallable-standard-object)) vs (describe (make-instance 'standard-generic-function)) .
There's a layout called layoutFuncallableStandardClass, defined in StandardClass.java, which has NAME as first slot, but that's for class objects with metaclass funcallable-standard-class, not for instances of these classes. I'll think a bit in the next days and try to either resolve my doubts or come up with another fix for the problem. Maybe I'm simply confused; wouldn't be the first time. :)
Well, to some extent I can see your problem. Indeed there seem to be no slots in the 'MOP:FUNCALLABLE-STANDARD-OBJECT class. The layoutFuncallableStandardClass is what confused me, but that's indeed the layout of the metaclass.
So, you're correct that the fix works by accident. The solution should be to add a slot by the name 'MOP::NAME to the FUNCALLABLE-STANDARD-OBJECT. That slot can contain the name of the object (ie function) for which the item is defined. In that case, we should probably remove the direct slot MOP::NAME on the standard generic function, since it's already defined on the superclass if we decide to do that.
Bye,
Erik.
On Apr 2, 2013, at 21:14, Erik Huelsmann ehuels@gmail.com wrote:
Hi Rudi,
On Tue, Apr 2, 2013 at 8:08 PM, Rudolf Schlatte rudi@constantly.at wrote: What makes me suspicious is the output of (describe (make-instance 'funcallable-standard-object)) vs (describe (make-instance 'standard-generic-function)) .
There's a layout called layoutFuncallableStandardClass, defined in StandardClass.java, which has NAME as first slot, but that's for class objects with metaclass funcallable-standard-class, not for instances of these classes. I'll think a bit in the next days and try to either resolve my doubts or come up with another fix for the problem. Maybe I'm simply confused; wouldn't be the first time. :)
Well, to some extent I can see your problem. Indeed there seem to be no slots in the 'MOP:FUNCALLABLE-STANDARD-OBJECT class. The layoutFuncallableStandardClass is what confused me, but that's indeed the layout of the metaclass.
So, you're correct that the fix works by accident. The solution should be to add a slot by the name 'MOP::NAME to the FUNCALLABLE-STANDARD-OBJECT. That slot can contain the name of the object (ie function) for which the item is defined. In that case, we should probably remove the direct slot MOP::NAME on the standard generic function, since it's already defined on the superclass if we decide to do that.
That's one solution, yes. I don't exactly know how / if slot inheritance works for objects created Java-side (which we do for FuncallableStandardObject and StandardGenericFunction), so it needs some experimentation. Luckily what we have now "works" and is not in any released version, so I can take some time to investigate in peace. Usually some piece of refactoring falls out which makes the overall code clearer and/or shorter.
Rudi
armedbear-devel@common-lisp.net