From: Christophe R. <cs...@ca...> - 2005-04-20 20:17:23
|
Matthew D Swank <ak...@co...> writes: > I cross posted since this list seems to have more activity. It would probably have been redirected here, because at least I am not about to give you a straightforward answer. :-/ > "You do not really understand something unless you can explain it to > your grandmother." =E2=80=94 Albert Einstein. While I think I probably could explain General Relativity to my grandmother, unfortunately I can't explain the slot access of funcallable-standard-instances. Last time I was in the area, I confess that I cargo-culted enough so that it seemed to work. We were implementing a hash value slot for standard-instances and funcallable-standard-instances, and I think I expressed my confusion thusly: ;;; FIXME: This seems to bear no relation at all to the CLOS-SLOTS ;;; slot in the FUNCALLABLE-INSTANCE structure, above, which ;;; (bizarrely) seems to be set to the NAME of the ;;; FUNCALLABLE-INSTANCE. At least, the index 1 seems to return the ;;; NAME, and the index 2 NIL. Weird. -- CSR, 2002-11-07 (defmacro fsc-instance-slots (fin) `(%funcallable-instance-info ,fin 0)) I have also observed in the past that there's something odd going on with CLOS/PCL discriminating functions, which don't allow themselves to be overridden: see bug #343. This is likely related to some weirdness happening in this area. However, there _is_ a solution to your particular case. I don't really recommend it; it's pretty horrible, but it comes about because the lisp calling convention is different for funcallable-standard-instances than it is for regular functions. If you replace > (defmacro promise (expr) > (let ((instance (gensym))) > `(let ((,instance (make-instance (quote promise) > :expr (quote ,expr)))) > (sb-pcl:set-funcallable-instance-function > ,instance > (delay ,expr)) > ,instance))) with (defmacro promise (expr) (let ((instance (gensym))) `(let ((,instance (make-instance 'promise :expr ',expr))) (sb-pcl:set-funcallable-instance-function ,instance #'(sb-kernel:instance-lambda () ,expr)) ,instance))) then I believe things start working. Since I don't really know why things start working, I can't exactly guarantee that these things will continue to work; I would love to be told what is going on in this area. However, I hope this gets you going, at least. Cheers, Christophe |