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

7 lines
175 B
Common Lisp

(defun counter-class ()
(let ((counter 0))
(lambda (msg)
(case msg
((:inc) (setq counter (+ counter 1)))
((:dec) (setq counter (- counter 1)))))))