Re: [gtk-list] Re: Gtk-- versus GTK+



> 
> Am I correct in assuming that in the first paragraph you're refering to
> our inability to use member functions as callbacks (because the first
> argument is always this)?

Yes, although I don't think that it is entirely impossible to use
a member function as a callback.   Some people have substituted the
first arguement with the C++ object and gotten it working.  However, 
that still doesn't make the connection safe as objects in C++ may come
and leave scope or be destroyed.  When that occurs unless there is no
class data used (thus a static function) the program will segfault.
It is that safty of connections that is a key feature of gtk--.
 
> If you are, then not only is it not safe, but
> will actually not work with a 100% certainty (unless it the callback uses
> no data whatsoever). And yes, I do have a 100 little static callbacks.
> 
> IF you're refering to something else, please explain more!

In addition to the safty of being able to connect to a C++ objects
directly, there is also the type safty issues to deal with.  C 
being a weakly typed language needs a good amount of casting.  However,
the user can easily make errors in that casting that C++ can catch.
(And is expected to as a language feature.)

Therefore, we implemented typesafe templates that allow the 
compiler to check if a function can safely be connected from 
to a signal.  This does come a cost.  If you have tried to compile
with gtk-- you will notice that it is quite slow.  This is because
of the extensive template matchine that is required to perform
that checking.   For most programmers it is well worth the cost.

--Karl



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]