Mike2012
Mike2012

Reputation: 7725

Is there anyway to "probe" a method in common lisp

My application allows the user to create their own methods indirectly and I later need to refer to these methods. I am wondering if there is a way (for error checking purposes) to test if a method exists without trying to execute it. If I just try and call the method and it doesn't exist this will crash my application.

Upvotes: 2

Views: 770

Answers (3)

Vatine
Vatine

Reputation: 21278

One solution would be to provide a "do nothing" GF method, dispatching on class T (the superclass of all classes). You'd need this for all GFs you're implementing methods on. It would also be possible to have that "do nothing" method log some data, maybe the class of each argument, for audit purposes.

Upvotes: 1

Svante
Svante

Reputation: 51511

It will not really crash, but signal a condition. If this condition is not handled, the debugger will be entered. See the CLHS, Section 9.1, for information on how to use the condition system.

Anyway, you can simply use fboundp for checking.

Upvotes: 5

Rainer Joswig
Rainer Joswig

Reputation: 139311

Also see the function FIND-METHOD : http://www.lispworks.com/documentation/HyperSpec/Body/f_find_m.htm#find-method

Upvotes: 7

Related Questions