Re: Sinkability considered harmful



Tim Janik wrote:
[...]
  MyObject *object;    /* move to declaration section */

  object = create_a_floating_object();
  some_container_add (container, object);
  my_object_unref (object);

In a sane world where your program doesnt explode
due to OOM conditions, it would read like this anyway:

    if ((object = create_a_floating_object()) != NULL) {
        some_container_add (container, object);
        my_object_unref (object);
    }

A widget is a resource, like a file descriptor or a
memory region; passing gtk_button_new() as an argument
to gtk_container_add() feels just as gross as passing
open() as an argument to read(), only the consequences
are acceptable.

The extra redundant lines of code (which are usually
taken care of by libglade anyway) IMO are a small price
to pay in exchange for:

    o Not having to open up myobject.h and check if it
      remotely descends from GtkObject and has to be
      treated specially.

    o Having unexpected surprises months later because
      one followed a perfectly acceptable logic: Its not
      a GtkWidget (someone mentioned a filechooser filter ?)
      so I'm not special casing it by assuming I dont own it.

My understanding is that floating widgets are deeply embedded
into GTK+ culture and are here to stay anyway so I can only
say: we have a confusing triple standard here (GObject,
GtkObject & GtkWindow), lets just do our best to not let that
get any worse.

My 2 cents,
                                 -Tristan




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