以下のようなコード設定があるとします
(defgeneric move (ship destination))
(defmethod move (ship destination)
;; do some fuel calculation here
)
(defmethod move :after ((ship ship) (dest station))
;; do things specific to landing on a station here
)
(defmethod move :after ((ship ship) (dest planet))
;; do things specific to landing on a planet here
)
ここで、宇宙船をステーションに移動したいとしますが、燃料計算の結果、船の燃料がマイナスの量になります (つまり、移動に十分ではありません)。
:after
必ずしもエラー状態を通知せずに修飾子が呼び出されないようにする方法はありますか?
私が電話を止めなければ、船は燃料を差し引かずに新しい場所に移動し、本質的にゲームが中断されます.