
On 20-9-2013 0:40, Markus Engel wrote:
Hi, as I wrote a few days ago: "If too many of these downcasts appear, it
looks
to me like a design error. There should probably be a virtual method
then."
Want to make a million virtual functions? ;)
:)
-----Ursprüngliche Nachricht----- Von: Jon Cruz [mailto:jon@...18...] Gesendet: Freitag, 28. Februar 2014 01:29 An: Markus Engel Cc: 'Johan Engelen'; 'Inkscape Devel List' Betreff: Re: [Inkscape-devel] Casting-macro replacement
On Feb 27, 2014, at 4:21 PM, Markus Engel wrote:
Ideally we can get to the situation where we don't need dynamic_cast<> at
all, and code will just work directly with standard C++ inheritance. Be careful, Johan's gonna laugh at you ;) . I said exactly that some time ago... look for "Code style question".
:-)
A bit part of the problem is that The C approach of GTK+ adds in the "is-a" checking on things. We often end up with things upside down from a C++ perspective. That could be part of the problem with getting a nice template. Since it is 'unnatural' C++, the code to pull it off is not as simple as we would like.
Instead of having low-level thing foo poke into bar which is a subclass of baz, we might want to have foo invoke a base 'state-has-changed' method of the parent class baz which in turn gets processed in bar via an overloaded virtual, etc.