[Openmcl-devel] "Smalltalk Model" related questions

Patrik Nordebo patrik at nordebo.com
Sun Jun 6 02:31:08 PDT 2004


On Tue, Jun 01, 2004 at 11:43:38PM +0200, Sebastian Nozzi wrote:
> 3) Function/Method look-up based on argument-form
> 
> Is it possible to tell the system to give me a list of all the functions
> and/or methods that conform to a specific argument-form? Say, "give me all
> functions which at least take as first parameter a member of class foo"
> 
> With this I could somehow look for all applicable functions to a class-type
> (which in Smalltalk you know by looking at the methods belonging to the
> class; in Lisp there is no specific way to gather equivalent information, I
> think)

This can't be done in just Common Lisp, but the Meta-Object Protocol
provides this kind of functionality.  See http://www.lisp.org/mop/,
and in particular

http://www.lisp.org/mop/dictionary.html#specializer-direct-generic-functions

This function gives you a list of all generic functions specialised
for a particular class.  If you want to look at only the first
argument it's a little more work, but can still be done by looping
over all symbols in all packages, and for each symbol that names a
generic function[1] looping over all its methods and looking at the
specializers you care about.

I believe OpenMCL implements those bits of the MOP necessary to do
this.

[1] Of course if you have generic functions that aren't actually named
by any symbols interned in packages, you won't find them, but that is
usually not much of an issue, I think.  There might be a way to just
get a list of all generic functions, but if so I don't know what it
is.



More information about the Openmcl-devel mailing list