From: Pascal C. <pc...@p-...> - 2007-09-07 22:24:26
|
There is a note in the specification for change-class, which states that you shouldn't call change-class in the middle of a method in which there are slot accesses to the respective object being changed. Isn't that a similar case? Shouldn't a CL be required to either make both change-class _and_ class redefinition behave sanely in such border cases or none of the two? In other words: Isn't this just an omission in the CL specification? Pascal On 7 Sep 2007, at 12:45, Nikodemus Siivola wrote: > I think this is legal. > > ;;; class redefinition in the middle of a method call > > (defclass will-change-sneakily () (here-now)) > > (defmethod slot-missing (class (instance will-change-sneakily) > slot-name operation &optional new) > (declare (ignore new)) > :slot-missing) > > (defun change-sneakily () > (eval '(defclass will-change-sneakily () ()))) > > (defmethod victim-of-a-sneaky-change ((x will-change-sneakily)) > (setf (slot-value x 'here-now) 42) > (change-sneakily) > (assert (eq :slot-missing (slot-value x 'here-now)))) > > (victim-of-a-sneaky-change (make-instance 'will-change-sneakily)) > > It breaks for us right now and AFAIK has always done so. This is > due to > permutation vector optimizations. The second SLOT-VALUE uses the same > instance-vector and permutation-vector as the first one, and > wrapper validity > is not checked in the middle of the call for optimized slot accesses. > > I think the only way to fix this is to compile the slot-value into > something > like > > (#:slot-value-using-permutations-<nnn> instance-vector permuation- > vector > permutation-index) > > index these functions by the specializer they refer to, and cause > the obsoletion > protocol to grovel over all such functions referring to > specializers that are > subtypep of the redefined class, and redefine them to trap -- and > then layer > on MORE MAGIC in the trap. > > Gah. I'm not about to attack this right now, but wanted to record > it for > posterity while I'm working in the neighbourhood ... and I wanted > you to > know that this was broken before I started working on pvectors. :) > > Cheers, > > -- Nikodemus > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Sbcl-devel mailing list > Sbc...@li... > https://lists.sourceforge.net/lists/listinfo/sbcl-devel -- Pascal Costanza, mailto:pc...@p-..., http://p-cos.net Vrije Universiteit Brussel, Programming Technology Lab Pleinlaan 2, B-1050 Brussel, Belgium |