Re: Return values from gtk2 widget (void) methods



On Tue, 22 Oct 2002, Dermot Musgrove wrote:

It occurred when I was writing Gtk2::Test - with (little) research I found
that many of the calls I tested return perl undef on success but some
return other things:

Call (success)                        Gtk-Perl                Gtk2-Perl
--------------                        --------                --------
Gtk2->init                    1                       0
Gtk2::Window->set_position    undef                   undef
Gtk2::HBox->add                       ref to widget added     undef
signal_connect                        connect id              connect id

[...]

So what should happen? As a perler, I like the idea of returning 'true
when they succeed and 'undef' otherwise.' like system calls. Success is
easy to spot and failures are not easily confused with anything else.

Hi gtk2perl hackers! :)

Just my 2cents: I think the most useful return values would be 'undef' on
failure, and function-dependent ref/value (which is 'true') on success,
for example Gtk2::HBox->add could return the HBox ref itself.

If a function want to return true, why not use the perl fact the
everything except undef,'' and 0 is true?

-- 
pozsy




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