Re: broken oop ?

Tim Janik wrote:
> On Fri, 14 May 1999, Sergio A. Kessler wrote:
> >
> > please, do not do the following...
> >
> > guint show_tabs           :1;
> >
> > in the gtk headers, the store in x bit is a pain in the ass for
> > making bindings for other languajes (ie. pascal), why not use
> > gboolean in case like this ?
> whether a certain flag is implemented through
> typedef enum { FLAG = 1 << 7 } XFlags;
> XFlags flags;
> or
> guint flag : 1;
> or
> gboolean flag;
> is actually a C implementation detail, with the former two having the
> advantage of packing bits together (for most compilers at least).

yep, but the big disadvantage of the former two, is that it make
the task of makings bindings for others languajes a true pain.
If a flag is declared like a gboolean, believe me that is absolutely
trivial to make the bindings.
I hear that one advantage for making the gtk in C is that is easy to
make bindings, and this is really true, but I think that the
authors of gtk can make our life much more easy if they don't
use things like that.

> i don't see how that relates to function bindings, you wouldn't want
> to map the widget fields there.
> usually flags like the above that are required by language bindings (i.e.
> flags that are a general part of the widget API) should come with
> appropriate accesor functions and should be exported through the widget
> arguments.

ok, but when you work with automated tools to make bindigs, doing
extra calls that are not part of the original API is, again, a
pain, usually you have to do it by hand.

> > Also, I think this broke the object oriented model, because in
> > this way I _must_ access a internal field of the object to know
> > the value of a property, wich should be managed _only_ by their
> > methods.
> >
> > for example, why exist:
> >
> > void gtk_notebook_set_show_tabs( GtkNotebook *notebook,
> >                                  gboolean     show_tabs);
> >
> > and not something like:
> >
> > gboolean gtk_notebook_get_show_tabs( GtkNotebook *notebook);  ??
> > or
> > gboolean gtk_notebook_tabs_visible( GtkNotebook *notebook);  ??
> >
> > the internal property show_tabs should be managed in the outside
> > by functions, never accesed directly, no ?
> gtk has been pretty lax on allowing users to *read* object fields, they
> should in generally considered private, but some object fields are documented
> to have certain values and may be evaluated by an outside user, e.g.
> GTK_BIN (bin)->child.
> however, you should never consider mutating object contents without using
> the provided accessors.

again, if gtk also provide accesors to _read_ (as well write) all 
the properties, gtk would be more cleaner and will allow more changes
to the internal fields without breaking compatibility, and, of course,
it will make the life of bindings maker _much_ more easy.

Conclusion: I'am not asking to modify gtk 1.2 (of course),  I'm asking
that if could be possible for authors following some guidelines in 
1.3 that could really help us *very* much.

For example:

- Use gboolean for boolean fields and boolean functions.
- Provide accesors for reading properties.
- Try to avoid to use something like "flag : x;" wich is not 
  supported in other languajes.

Could be possible in 1.3, so the next 1.4 become trivial to
make bindings for ?
Please ?

  |    Sergio A. Kessler
-O_O-  Keep working at it... you will either succeed, or become an

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