3 ms·
What is a generic function?
by bmitc 5y ago
What is a generic function?
- pfdietz 5y agoIt's a function that has one or more required arguments, and a set of methods. Each method has a class (or an EQL specifier) associated with each argument. When the generic function is called, the best method for which each actual parameter is in the corresponding argument's class is invoked. Think of it like a method in ordinary OO, but it can dispatch on multiple arguments. There's also some interesting stuff on top of this (method combinations) that allow multiple methods to be invoked and their results combined. https://en.wikipedia.org/wiki/Generic_function#In_Common_Lisp_Object_System https://en.wikipedia.org/wiki/Generic_function#In_Common_Lis... http://clhs.lisp.se/Body/07_f.htm http://clhs.lisp.se/Body/07_f.htm
- HansW3510 5y agoFor an interesting application, see how https://github.com/joaotavora/snooze#rationale https://github.com/joaotavora/snooze#rationale maps generic functions to HTTP/REST.