On Aug 31, 2004, at 6:21 PM, Andy Dent wrote:
Guyren G Howe wrote recently
I feel obliged herein to insert my occasional comment that, RB's docs
notwithstanding, the preferred method of class extension in REALbasic
is to use events, not method overriding.
I don't necessarily agree but it made me think about dispatching
overhead.
Events on controls in windows are bound at editing time (even earlier
than compile-time) which is why the IDE knows to hide an event in the
editor if it is handled in a parent class.
I infer that they are not dispatched through a virtual method lookup.
This implies, if you have a method you want called often enough for it
to be important to optimise, that events would be better than methods
(eg: something called per pixel, processing every frame of a movie or
in a large image).
However, thinking about it, I'm not sure there's enough context for
early binding to occur in events used outside of windows.
Maybe outside a window, event calls are straight virtual function
calls.
Maybe they always are?
I've tested this out; there is no difference in execution speed as far
as I can determine -- except in the case of unimplemented
methods/events. Unimplemented methods are called, but unimplemented
events are not. Your mileage may vary.
--------------
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|