transcendental-lisp/lisp/object/multiple-methods.lisp

9 lines
253 B
Common Lisp
Raw Normal View History

2017-03-08 11:14:44 -05:00
;; This is based on an example presented in "Let Over Lambda" by Doug Hoyte.
(defun counter-class ()
(let ((counter 0))
(lambda (msg)
(case msg
((:inc) (setq counter (+ counter 1)))
((:dec) (setq counter (- counter 1)))))))