http://www.newton-inc.com/dev/techinfo/qa/qa.htm
self
", you can speed things up by doing the lookup explicitly once before executing the loop, and using the call statement to execute the function within the body of the loop.
f1 := {myFn: func() 42};
f2 := {_parent: f1};
f3 := {_parent: f2};
f4 := {_parent: f3};
f5 := {_parent: f4};
f5.test1 := func ()
for i:=1 to 2000 do call myFn with ();
f5.test2 := func() begin
local fn := myFn;
for i:=1 to 2000 do call fn with ();
end
/* executes with a noticeable delay */
f5:test1();
/* executes noticeably faster */
f5:test2();
Use this technique only for functions that don't use inheritance or the self keyword.GetTrapAddress
to get a trap's real address and calling it directly to avoid the overhead of trap dispatch.