Re: [gtk-list] Re: I want to understand
- From: Havoc Pennington <rhp zirx pair com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: I want to understand
- Date: Wed, 14 Apr 1999 11:40:44 -0400 (EDT)
On Wed, 14 Apr 1999, Jonathan Mark Brooks wrote:
>
> > 4) Using C++ as the base would make other language bindings more difficult
> > to write (??)
>
> Disagree. Actually, the object-oriented features of C++ would make it
> much easier to design bindings for other languages. You can always limit
> wrappers/container classes, but adding features not supported by the
> language is another matter...
>
The reason language bindings are easy to write for Gtk is not that it's
written in C per se (though that helps some), but rather that it
implements its own custom object/type/signal system in C. This system is
extremely flexible; scripting languages can query and alter all sorts of
things on the fly. So Gtk already handles a lot of the annoying framework
you need when dealing with dynamically-typed or garbage collected
languages, and its object system is flexible enough that you could
conceivably add new object subclasses written in the other language,
though not all the bindings support this.
Understanding why this is true requires spending a lot of time with
gtktypeutils.c, gtksignal.c, and gtkobject.c. It's not documented so well.
guile-gtk has a README that's the closest thing to type system docs.
I'm not sure I understand it 100%, but if you dig around in that code some
you'll begin to appreciate it.
You could obviously implement this in C++, since you can implement it in
C, but the point is that you can't just use the C++ object system, because
C++ has a static, compile-time object system (for the most part). Since
you'd be reimplementing an object system anyway, C++ doesn't get you as
far as you might think.
Remember: no C/C++ flamewars here. Keep it on-topic about Gtk+. :-)
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]