defgeneric
defgeneric(
s_functionName
( s_arg1
[ s_arg2 ... ]
)
[ g_exp ... ]
)
=> t
Description
Defines a generic function with an optional default method. This is a macro form. Be sure to leave a space after the function name.
Arguments
|
s_functionName
|
Name of the generic function. Be sure to leave a space after the function name.
|
|
s_arg1
|
Any valid argument specification for SKILL functions, including @key, @rest, and so forth.
|
|
g_exp
|
The expressions that compose the default method. The default method is specialized on the class t for the first argument. Because all SKILL objects belong to class t, this represents the most general method of the generic function and is applicable to any argument.
If g_exp is omitted, then an error message appears when the generic function is called and no more specific method is found. For example:
*Error* myFunc: no applicable method for the class - (fixnum).
|
Value Returned
|
t
|
Generic function is defined.
|
Examples
ILS-<2> defgeneric( whatis ( object )
printf(
"%L is an instance of %s\n"
object className( classOf( object))
)
) ; defgeneric
ILS-<2> whatis( 5 )
5 is an instance of fixnum
t
ILS-<2> whatis( "abc" )
"abc" is an instance of string
t
Related Topics
Generic Functions and Methods
defmethod
generic functions
Return to top