From: Hardeep Johar
Subject: Controlling method execution sequence in CLOS/CLIPS: THANK YOU.
Date: 
Message-ID: <15405@rnd.GBA.NYU.EDU>
Thanks to all those who responded to my question on controlling the
method execution sequence in CLOS and CLIPS. There were two solutions
suggested, both clearly demonstrating my inadequate knowledge of CLOS!

1. Use around methods instead of before methods.  This is the simplest
answer, and works for CLIPS as well as CLOS.

2. Stick to before methods but use catch and throw to trap error
conditions as in the example below. This was suggested by George
Kiczales. Unfortunately this does not work in CLIPS because there
does'nt seem to be any equivalent of catch and throw.

(defclass bank-account ()
  ((balance :accessor balance)))

(defmethod withdrawal :around ((account bank-account) amount)
  (catch 'insufficient-funds
    (call-next-method)))

(defmethod withdrawal ((account bank-account) amount)
  (let ((old-balance (balance account)))
    (setf (balance account) (- old-balance amount))))

(defmethod withdrawal :before ((account bank-account) amount)
  (when (> amount (balance account))
    (pprint "Insufficient funds.")
    (throw 'insufficient-funds ())))

Thanks again to all who replied.

Hardeep.
-- 
****************************************************************************
Hardeep Johar                                       ······@rnd.stern.nyu.edu
Work phone: (212) 998-4205.
****************************************************************************