Nobody said:
Perhaps you should explain exactly what's so terrible about the API?
Personally, I don't consider having to perform explicit up-casts to be an
unbearable burden (down-casts should be explicit anyhow).
having to use cast-macros itself is ugly, FWIW...
it also makes it a little harder to mechanically generate code targetting
GTK IME (the code-writing logic has to be specialized for GTK and possibly
the task at hand).
....
There's no need for that. Neither GTK+ nor Xt work that way; each class
has class and instance structures which extend the corresponding parent
structures.
yes, that is how they work.
this works, granted...
I, OTOH, tend to use a very different strategy, both for object
representation as well as for API design.
my design strategy doesn't tend to be particularly C++/Java style
class/instance, but has also been influenced by things like CLOS and Self.
but, anyways, often partly flattening the class-tree actually saves some
effort (IOW: it is a fairly convinient strategy), as really common stuff can
be much more readily shared. this way, the particular subclasses can instead
focus on providing different behavior, rather than worrying lots about
providing a different structural representation.
I have actually used one (domain-specific) language that itself took this to
an extreme:
pretty much all object types (all their data, methods, ...) used a single
massive structure-type (produced by the compiler), typically differing only
in which fields or methods were actually used by a given object or "class"
(unused methods were NULL).
so, it is not unworkable (actually, in a C based implementation, may
actually be more convinient IME), but granted, if done poorly, can waste
additional memory.
the Linux kernel tends to use kind of a hybrid strategy in a few places (the
"subclasses" could be regarded as having been union'ed into the
"superclass"), which is sort of the reverse of the parent-inclusion route
(it leads also to the root object having the size of the largest
"subclass").
....
but, as I see it, "OO" is not really about how ones' "classes" are laid out
in memory...