realbasic-nug
[Top] [All Lists]

Events faster than virtual methods?

To: realbasic-nug at lists dot realsoftware dot com
Subject: Events faster than virtual methods?
From: Andy Dent <dent at oofile dot com dot au>
Date: Wed, 1 Sep 2004 06:21:16 +0800
Delivered-to: realbasic-nug at lists dot realsoftware dot com
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?

_______________________________________________
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>

<Prev in Thread] Current Thread [Next in Thread>