Special methods

Methods that have special side effects, or are called automagically at certain times.

forward

If you try to call a message on an object, and that message is not defined (nor in parent objects), but forward is, then forward will be called. It can be used to handle these cases (attributes that aren't found).

Inside forward, the name of the message that was not found can be retrieved by call message name.

MyObject forward := method(
   writeln("You tried to access: ", call message name)
)

The manual has several other ways to get information:

(More about the Call object.)

init

(todo...)

asString

Not really "magic", but this is called when print and friends (or the interactive interpreter) need a string representation of an object. Similar to __str__ in Python. For example:

Io> m := Map clone
==>  Map_0x7447a0:
Io> m
==>  Map_0x7447a0:

# change asString...
Io> Map asString := method("je grootje!")
==> method("je grootje!")

# try printing m...
Io> m
==> je grootje!