Re: Return values from gtk2 widget (void) methods

On Tue, 22 Oct 2002 15:51:23 +0100, Dermot Musgrove wrote:
goran kirra net wrote:
2. On the other hand it would be nice to have a consistant
   return value scheme like "0 (zero)"=failed, "not 0"=success
   so we could do perlish things like:
   $obj->set_label('xx') && $obj->show;
I reckon that undef is better for failure as it is not the same as 0.
eg 0 is returned by gtk_window_get_resizable when the window is not
resizable (false) - but it represents a successful function call.

Unfortunately, 0 and undef are both false. The DBI gets around this by
returning undef on failure (which is false), and '0E0' on zero-valued
success (which is true, but zero in numeric context). If you're only 
returning a success/fail value without any different success values,
then stick to Perl's 1/'' (or 1/undef) values. There are even &PL_sv_yes
and &PL_sv_no values available in C code for this purpose, and

        Peter Haworth   pmh edison ioppublishing com
"For example, I could be a sentient PERL script.
 That pretty much assumes that someone brilliant enough to write me
 was also stupid enough to program in PERL. Not a likely explanation."
                -- Terry Lambert

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