Re: [RFC] export TRUE and FALSE from someplace
- From: muppet <scott asofyet org>
- To: gtk-perl list <gtk-perl-list gnome org>
- Subject: Re: [RFC] export TRUE and FALSE from someplace
- Date: Tue, 20 Jan 2004 19:52:47 -0500
On Tuesday, January 20, 2004, at 06:49 PM, Jens Luedicke wrote:
scott asofyet org wrote:
i have grown very annoyed of needing to add
use constant TRUE => 1;
use constant FALSE => 0;
atop every gtk2-perl program i write. [..]
Hmm. I'm using 1 and 0 for TRUE and FALSE.
Is there a special need for those constants?
no technical need. i prefer them for maintenance.
(i'd stop there, because most of us know what that means, but i'll give
some examples for those who may be wondering.)
as a contrived example: at a glance, which of the arguments to
Gtk2::Box::pack_start is the integer padding value?
$box->pack_start ($widget1, 0, 0, 0);
$box->pack_start ($widget2, 1, 1, 1);
it's a lot easier to tell with
$box->pack_start ($widget, FALSE, FALSE, 0);
$box->pack_start ($widget, TRUE, TRUE, 1);
more do the point, you may wonder what's magical about returning 1 from
this closure used as a signal handler, and whether you can return
positive or negative or even fractional values:
$window->signal_connect (delete_event => sub { 1 });
but it's obvious here that it returns boolean.
$window->signal_connect (delete_event => sub { TRUE });
and in this case, returns true to stop event propagation, which keeps
delete-event from destroying a toplevel window.
--
muppet <scott at asofyet dot org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]