Subject: Re: Request for comments on CLOS code
From: (Rob Warnock)
Date: Mon, 30 Aug 2004 20:55:23 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Peter Lewerin <> wrote:
| (Peter Lewerin) wrote
| > Of course.  With this added requirement, a tail slot makes sense:
| Ooops.  Forgot to null the tail slot when the last element is
| dequeued.  (Actually, it doesn't matter, but anyway.)
|     (defmethod dequeue :after ((q constant-time-fifo))
|       (with-slots (contents tail) q
|         (unless contents
|           (setf tail nil))))

Alternatively, you could just as easily do that right
in the primary method itself:

    (defmethod dequeue ((q constant-time-fifo))
      (with-slots (contents tail) q
	 (pop contents)
	 (unless contents
	   (setf tail nil)))))

That way, somebody reading your code doesn't have to
go looking for the :AFTER method. [Plus, it's likely
to be somewhat faster as well.]

Note: I don't have anything against :AFTER methods in
general, but it seems a bit excessive in this case.


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607