Proposing the removal of virtual_hooks (or how you can add a virtual method without using "virtual")
Frans Englich
frans.englich at telia.com
Sun Mar 5 22:18:16 GMT 2006
On Sunday 05 March 2006 16:50, Thiago Macieira wrote:
> Frans Englich wrote:
> >On Saturday 04 March 2006 11:18, Thiago Macieira wrote:
> >> I'd like to propose a change of policy in the KDE libraries: remove
> >> all virtual_hook functions from QObject-derived classes.
> >>
> >> The reason for that is that we *already* have a virtual_hook function
> >> in those classes and it's called qt_metacall. It's automatically
> >> generated by moc, so we're safe that it'll always exist.
> >
> >Another way to preserve BC is to use the visitor/double dispatch
> > pattern. It can be argued to be a bit heavy code-wise, but achieves the
> > goal and can also be fast, depending on various factors. Major
> > pros/cons:
>
> Would you mind elaborate on what that is?
Ok, attached is a visitor pattern discussion. I'm told it is in GOF's Pattern
Design book, you can read about it in wikipedia, google for it, etc. I might
very well be "wrong" on this, show an incomplete picture, and so forth. I
have never seen anyone use it for the purpose of preserving BC, but by my
common sense(TM) it should be possible to use it that way.
I use the visitor pattern in kdenonbeta/kdom/xpath, but that's mainly for
other reasons(not for preserving BC).
Cheers,
Frans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: visitor_example.cpp
Type: text/x-c++src
Size: 2958 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060305/12eabc3e/attachment.cpp>
More information about the kde-core-devel
mailing list