10.13.6.19 instance_method/1 declaration

Synopsis

:- instance_method +Name/+Arity.

Arguments

Name
atom
Arity
integer

Description

The message Name/Arity is declared to support instance methods in a class. This means that instances of this class, and its descendants, may each define their own methods for this message.

A method defined for this message by the class is considered the default method for the message. An instance that does not define its own method uses the default. Defining a new method overrides this default method; there is no need to explicitly remove it.

An instance method is installed in an instance of the class with the define_method/3 predicate. An instance method is removed from an instance of the class, reverting to the default method, with the undefine_method/3 predicate.

Must occur within the scope of the class definition. Only applies to send messages.

See Also

class_method/1, define_method/3, undefine_method/3


Send feedback on this subject.