Re: GIO API review



Hi,

Martyn Russell wrote:
I don't really see the need for adding symbols to the library to
represent 0. If there is only one "flag" in each of these that matters,
doesn't it make more sense to just have a boolean?


Flags are almost always preferable to booleans, compare -

 gtk_box_pack_start(box, child, TRUE, FALSE, 0)

 gtk_box_pack_start(box, child, GTK_PACK_EXPAND, 0)

 g_file_monitor_file(file, TRUE, NULL);

 g_file_monitor_file(file, G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS, NULL);

Boolean versions require referring to docs in order to read the code.

Of course if the function name identifies the boolean, it's different:

 gtk_widget_set_sensitive(widget, TRUE)

is fine.

Flags are also extensible, of course, while a boolean is not.

Havoc



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