next up previous contents index
Next: More Methods for Rot2d Up: Writing Methods Previous: The Methods "get-info" and

The "universal" Method

 

As described in section 5.2.1 GRAPE searches for a method "universal" if the method that is send to an instance is neither found in the instance's class nor in its superclasses. If the method

   GRAPE(inst, "universal")(method)
INSTANCE * inst
char * method
is found, it is send to the instance with the method method that was originally called as parameter. If you supply an "universal" method for a class the method method can for example be passed on to one of the instance variables of the instance inst.

Be careful: only parameterless methods can be called via universal, any argument passed to the original method is lost. Therefore if the method method needs parameters on the class it is send to this won't work. Because the GRAPE function doesn't know if a method needs parameters it will always try to use "universal" if the original method wasn't found.

The behaviour of the GRAPE function can be influenced by calling one of the methods

   tex2html_wrap43988    tex2html_wrap43990
INSTANCE/CLASS * obj
"unset-universal-send" switches the universal mode off, "set-universal-send" switches it on again (by default it is on). Be careful when switching universal mode off, many classes like Scene, TimeScene and Time_Object rely on this mechanism.



SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.