informaticsEn 2022-07-19 11:26:58
389

Generic functions

In Common Lisp Object System

In some systems for object-oriented programming such as the Common Lisp Object System (CLOS) and Dylan, a generic function is an entity made up of all methods having the same name. Typically a generic function is an instance of a class that inherits both from function and standard-object. Thus generic functions are both functions (that can be called with and applied to arguments) and ordinary objects. The book The Art of the Metaobject Protocol explains the implementation and use of CLOS generic functions in detail. 1

A generic function is a function whose behavior depends on the classes or identities of the arguments supplied to it. A generic function object contains a set of methods, a lambda-list, a method combination type, and other information. The methods define the class-specific behavior and operations of the generic function; a method is said to specialize a generic function. When invoked, a generic function executes a subset of its methods based on the classes of its arguments. 2

Further information about generic functions

https://gigamonkeys.com/book/object-reorientation-generic-functions.html

Introduction to Generic Functions

https://clos-mop.hexstreamsoft.com/concepts/#generic-functions

You can get the example

https://gist.github.com/juan-reynoso/a6ce52e2d9569abc7e12f92224499dc6


References

1 https://en.wikipedia.org/wiki/Generic_function

2 https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node261.html

Back to index