[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-devel
Subject:    Re: GIO API review
From:       Havoc Pennington <hp () redhat ! com>
Date:       2007-12-13 19:33:27
Message-ID: 47618907.7080903 () redhat ! com
[Download RAW message or body]

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

_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic