anchor.diff:      initargs))
   
   
  -;; TODO: rewrite like initialize-instance :before
  -(defmethod reinitialize-instance ((instance transactional-object)
  -                                  &rest initargs &key &allow-other-keys)
  -  "For every transactional slot, wrap its initarg into a tvar."
  -
  -  (let1 initargs (wrap-transactional-slots instance initargs)
  -
  -    ;; Disable recording so that slots initialization is NOT recorded to the log.
  -    ;; Show-tvars so that (setf slot-value) will set the tvar, not its contents
  -    (without-recording-with-show-tvars
  -      (apply #'call-next-method instance initargs))))
  +;; live migration from STMX v1.9.0:
  +;; we must remove the methods INITIALIZE-INSTANCE
  +;; and REINITIALIZE-INSTANCE specialized for TRANSACTIONAL-OBJECT
  +(eval-when (:execute)
  +  (undefine-method 'initialize-instance   'transactional-object)
  +  (undefine-method 'reinitialize-instance 'transactional-object))
  
positive.code: - the metaclass is TRANSACTIONAL-CLASS
  - it internally defines a method INITIALIZE-INSTANCE :before, do NOT redefine it"
    `(progn
       (eval-always
         (,defclass ,class-name ,(ensure-transactional-object-among-superclasses direct-superclasses)
           ,(adjust-transactional-slots-definitions direct-slots class-name direct-superclasses)
           ,@class-options
           ,@(stmx.lang::get-feature 'tclass-options)
           (:metaclass transactional-class)))
       (define-method-initialize-instance-before ,class-name)))
  
  
  
  
negative.code:     (nreverse slots)))
  
  
  (defun undefine-method-before (generic-func-name class-name)
    "Remove from GENERIC-FUNC-NAME the method qualified :BEFORE and specialized for CLASS-NAME"
    (let* ((generic-func (fdefinition generic-func-name))
           (method (find-method generic-func '(:before) `(,class-name) nil)))
      (when method
        (remove-method generic-func method)
        t)))
    
  
  (defun undefine-method (generic-func-name class-name)
    "Remove from GENERIC-FUNC-NAME the method specialized for CLASS-NAME"
    (let* ((generic-func (fdefinition generic-func-name))
           (method (find-method generic-func nil `(,class-name) nil)))
      (when method
        (remove-method generic-func method)
        t)))
  
  
  
  (defmacro define-method-initialize-instance-before (class-name direct-slots)
    (flet ((%extract-slot-name (slot)
             (if (symbolp slot)
                 slot
                 (first slot)))
           (%is-slot-tx (slot)
             ;; a slot is transactional *unless* defined :transactional nil
             (if (symbolp slot)
                 t
                 (let* ((tx-and-rest (member :transactional slot))
                        (tx-opt (second tx-and-rest)))
                   (or tx-opt (not tx-and-rest))))))
  
      (let ((transactional-direct-slots
             (loop for slot in direct-slots  
                when (%is-slot-tx slot)
                collect slot)))
  
        (block nil
          (unless transactional-direct-slots
            (return
              `(eval-when (:execute)
                 (undefine-method-before 'initialize-instance ',class-name))))
  
          (with-gensym obj
            `(defmethod initialize-instance :before ((,obj ,class-name) &key &allow-other-keys)
               ,(format nil "Put a TVAR into every transactional direct slot of ~S
  *before* the normal slots initialization." class-name)
               (stmx::without-recording-with-show-tvars
                 ,@(loop for slot in transactional-direct-slots  
                      collect `(setf (slot-value ,obj ',(%extract-slot-name slot)) (tvar))))))))))
  
          
  
  
  