A method which is implemented outside TOM (say, in C) can have a dynamic
return type and dynamic argument types. A dynamic type implies anything
can be passed and will be accepted. The type of the value actually
passed to the method is encoded in the selector, which the method
receives as the implicit second argument (after self
).
Similarly, the method implementation can deduce the expected return type
from actual selector. The dynamic type is used by, for instance, the
perform :
method, which is defined as
extern dynamic perform selector sel : Array arguments = nil;
If perform :
would be invoked as
int a, b, c; (a, b, c) = [foo perform bar]
then it would be a (fatal) runtime error if the selector denoted by
bar
did not return a tuple of three integers.
[Note: Currently, the possibilities of the dynamic
type are
somewhat limited. For instance, the compiler insists on being able to
deduce the actual type used for something declared dynamic. Thus, for
example, the following doesn't work, even though it should, really:
[foo setValue [foo valueOfVariableNamed "bar"] ofVariableNamed "bar"]
End note.]
Go to the first, previous, next, last section, table of contents.