Re: Question about call-next-method

"Tim Bradshaw (as tfb at cley dot com)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
On 16 Nov 2025, at 15:21, David McClain (as dbm at refined-audiometrics dot com) <[email protected]> wrote:

So it appears that CLOS (in LW) provides a collection of next methods, CLOS::*NEXT-METHODS*, as a dynamic binding, before calling your method. So if you were to redefine some more specific method anywhere along the current call-chain, you would likely not discover the new construction during this same method call.

Exactly. You can check this by just writing a method which returns #'call-next-method, and poking around in that with the inspector. The function closes over the list of next methods.

The object does get its class changed, but the selection of next-methods has already been done by the time you change the class, and so CALL-NEXT-METHOD won’t appear to do the correct thing.

It does do the correct thing I think. The spec says

When providing arguments to call-next-method , the following rule must be satisfied or an error of type error should be signaled: the ordered set of applicable methods for a changed set of arguments for call-next-method must be the same as the ordered set of applicable methods for the original arguments to the generic function .

So you're not meant to do things which do that.

Still less should the behaviour of programs which might add, redefine or remove methods to a generic function while it is being called be defined. People who write programs which do that should be politely refused any further access to computers. CLOS is hard enough to get right anyway (especially if you include the MOP) without adding i sane requirements like that to it.

--tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.