Re: Sinkability considered harmful
- From: Tristan Van Berkom <tvb gnome org>
- To: Owen Taylor <otaylor redhat com>
- Cc: Federico Mena Quintero <federico ximian com>, GTK+ development mailing list <gtk-devel-list gnome org>, Tim Janik <timj imendio com>
- Subject: Re: Sinkability considered harmful
- Date: Wed, 04 Jan 2006 11:48:31 -0500
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]