Zach Beane (xach) wrote,

Lisp Usenet classics

Tags: lisp

Anonymous

October 4 2007, 06:21:19 UTC 6 years ago

  • New comment

Re: Object Orientation and what it means in Common Lisp

It might help to take a look at MAKE-INSTANCE. I think it has the protocol you want.

(defgeneric make-instance (class &rest initargs))

You can specialize on the first argument and have the interpretation of the rest of the argument list handled by the various methods. Using this pattern, you can write:

(talk (make-instance 'dog))
(talk (make-instance 'human) :word "lisp")

Aside: Note that MAKE-INSTANCE plays a little trick where (make-instance 'foo ...) simply calls (make-instance (find-class 'foo) ...).

Eric

Error

Anonymous comments are disabled in this journal

default userpic

Your reply will be screened

Your IP address will be recorded