Re: Sinkability considered harmful



Owen Taylor wrote:
[...]
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);
    }


[ taking the troll-bait and digressing :-) ]

And so, what you do in the other branch of this if statement?

Heh,
    Its not directly on-topic but I did bring it up; the
answer would obviously be:

    a.) Fail gracefully
    b.) Fall back to "my_object"less mode (heh)

In fact; I do write alot of code that looks like:
========================================================
if ((w = glade_xml_get_widget (xml, "foo")) != NULL) {
    my_app->foo = w;
    g_signal_connect (G_OBJECT (w), "clicked",
                      G_CALLBACK (foo_clicked), my_app);
}
========================================================

And then later go on to do:
========================================================
/* Show or hide this button if its available in this
 * particular skin.
 */
if (my_app->foo != NULL)
    gtk_widget_show (my_app->foo);
========================================================

The idea is to support a wide variety of features in the
code-base and also support a wide variety of products
that dont all include all the "dashboard extra features".

Ofcourse the point was to demonstrate that being responsable
for allocated resources is not that bad; actually its
the programmers responsability (a responsability that gets
harder to fullfill when there are dual and tripple standards...).

Cheers,
                       -Tristan



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