Re: broken oop ?



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).
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.

> 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.

> 
> Sergio
> 

---
ciaoTJ



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