(defclass <cartesian> ()
((x :initform 0 :initarg :x)
(y :initform 0 :initarg :y)))
(defclass <polar> ()
((r :initform 0 :initarg :r)
(theta :initform 0 :initarg :theta)))
(defmethod update-instance-for-different-class :before ((old <cartesian>) (new <polar>) &key)
(let ((x (slot-value old 'x))
(y (slot-value old 'y)))
(setf (slot-value new 'r) (sqrt (+ (* x x) (* y y)))
(slot-value new 'theta) (atan y x))))
(defmethod update-instance-for-different-class :before ((old <polar>) (new <cartesian>) &key)
(let ((r (slot-value old 'r))
(theta (slot-value old 'theta)))
(setf (slot-value new 'x) (* r (cos theta))
(slot-value new 'y) (* r (sin theta)))))
(setq pos1 (make-instance '<polar> :r (sqrt 2) :theta (/ pi 4)))
(setq pos2 pos1)
(class-of pos1)
(change-class pos1 '<cartesian>)
(class-of pos1)
(slot-value pos1 'x)
(slot-value pos1 'y)
(class-of pos2)
(change-class pos1 '<polar>)
(class-of pos1)
(slot-value pos1 'r)
(/ (slot-value pos1 'theta) pi)