Re: Sinkability considered harmful



On Wed, 2006-01-04 at 12:33 +0100, Tim Janik wrote:

>    1. "The main motivation for providing floating references is C convenience"
>       http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#floating-ref

That's inaccurate.  We added floating references to avoid breaking
existing code.

> so asid for maintaining API compatibility, there is no technical need for
> a floating flag.

Exactly!  And read on.

> one can maintain your claim from a purely technical perspective.
> however, it is not very helpfull for everyday coding in C. let's
> investigate what the floating flag buys your in every day C code.
[snip]

C is hard.  Memory management in C is hard.  People have to get over it.

To summarize the inconsistencies that we have right now:

1. some_object_new() may give you a floating or non-floating reference,
depending on whether SomeObject is a child of GtkObject or GObject.
Pain for the developer and language bindings.

2. Bar *foo_get_bar(Foo *foo) may or may not give you a new reference to
bar.  We don't always follow the convention that "get()" means you get a
new reference, and "peek()" means you don't get a new reference.  Pain
for the developer and language bindings.  Special pain for developers of
threaded applications.

3. g_object_get (obj, "property", @prop, NULL) gives you a new
reference.  Or does it?  I can never remember, so I always have to
consult the implementation of g_value_object_copy_value().  Pain for the
developer and language bindings.  This also makes 
g_object_get (foo, "bar", ...) dangerously asymmetric with respect to
foo_get_bar().

Pain, pain, pain.

I do *not* want to propagate this sort of inconsistencies.  That is why
I advocate keeping floating references in GtkObject and GtkWidget as a
historical artifact, rather than as recommended practices.

GtkObject has *ONE* interesting feature, and it is not floating
references --- it is the ::destroy() method.  In particular, for
GtkWidget this of course means "ask your parent to unparent you and
disappear from the widget hierarchy right away".

API freeze for GNOME 2.14 is approaching quickly.  Can we please back
out GObject floating references soon?

  Federico




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