;;; CLOS 4: DISPATCH ON A VALUE ;;; ;;; An (EQL x) specializer picks a method for one specific value. ;;; It works for numbers, characters and symbols - values that are ;;; their own identity. (defgeneric serve (customer)) (defmethod serve (customer) "one espresso") ;; TODO: The customer 'vip gets a muffin too. (defmethod serve ((customer (eql 'vip))) "espresso") ;;; ------------------------------------------------------------------ ;;; Checks. Read them - they tell you what to aim for - but leave ;;; them unchanged. ;;; ------------------------------------------------------------------ (check-equal "a free muffin too" (serve 'vip)) (check-equal "one espresso" (serve 'ada))