callNextMethod
callNextMethod( [g_arg... ] ) =>g_value
Description
Calls the next applicable method for a generic function from within the current method. Returns the value returned by the method it calls.
This function can only be (meaningfully) used in a method body to call the next more general method in the same generic function.
You can call callNextMethod with no arguments, in which case all the arguments passed to the calling method will be passed to the next method. If arguments are given, they will be passed to the next method instead.
Arguments
Value Returned
Examples
If you call the callNextMethod function outside a method you get:
ILS-<2> procedure( example() callNextMethod() )
example
ILS-<2> example()
*Error* callNextMethod: not in the scope of any generic function call
This example also shows the effect of incrementally defining methods:
ILS-<2> defgeneric( HelloWorld ( obj )
printf( "Generic Hello World\n" )
)
=> t
ILS-<2> HelloWorld( 5 )
Generic Hello World
=> t
; t is the superclass of all classes
ILS-<2> defmethod( HelloWorld ((obj t ))
printf( "Class: %s says Hello World\n" 't )
)
=> t
ILS-<2> HelloWorld( 5 )
Class: t says Hello World
=> t
; systemObject is a subclass of t
ILS-<2> defmethod( HelloWorld ((obj systemObject ))
printf( "Class: %s says Hello World\n" 'systemObject )
callNextMethod()
)
=> t
ILS-<2> HelloWorld( 5 )
Class: systemObject says Hello World
Class: t says Hello World
=> t
; primitiveObject is a subclass of systemObject
ILS-<2> defmethod( HelloWorld (( obj primitiveObject ))
printf( "Class: %s says Hello World\n" 'primitiveObject )
callNextMethod()
)
=> t
ILS-<2> HelloWorld( 5 )
Class: primitiveObject says Hello World
Class: systemObject says Hello World
Class: t says Hello World
=> t
; fixnum is a subclass of primitiveObject
ILS-<2> defmethod( HelloWorld (( obj fixnum ))
printf( "Class: %s says Hello World\n" 'fixnum )
callNextMethod()
)
=> t
ILS-<2> HelloWorld( 5 )
Class: fixnum says Hello World
Class: primitiveObject says Hello World
Class: systemObject says Hello World
Class: t says Hello World
=> t
ILS-<2> HelloWorld( "abc" )
Class: primitiveObject says Hello World
Class: systemObject says Hello World
Class: t says Hello World
=> t
Related Topics
Return to top