So there are two issues. One is an English language issue (you have to be super careful because every English word is overloaded with multiple programming meanings. Eg when you write “call” it isn’t clear whether you mean “name” or “invoke/apply”.) but that doesn’t really matter
The other issue is that you don’t know what a generic function is. Here is a quick explainer.
A generic function has (roughly) three parts:
- A lambda list
- A method combination
- A set of methods
A method has three parts
- A specialised lambda list
- Some code
- Something related to the method combination (typically
nil
)
When you call a generic function this happens:
- It looks at the types of the arguments
- Various rules are applied to order the methods by specificity
- The method combination says how to combine these into a function
- The code for the combined function is generated and compiled
- The generated function is called with the arguments.
Steps 2-4 are typically cached.
Step 3 comes in roughly two forms:
- Standard method combination:
- All
around
methods are called
- Then all
before
methods
- Most specific method is called (with an appropriate chain of methods set up for
call-next-method
)
- Then all
after
methods
- Result is returned through all the
around
methods
- Other method combinations typically apply all the methods’ results to some operator like
and
or progn
or append
.
To add a method to the set of methods of a generic function one typically uses defmethod
with the same name as the generic function