On 12 Apr 2005 03:46:24 -0700, Gisle Aas <[EMAIL PROTECTED]> wrote:

> [EMAIL PROTECTED] (Ton Hospel) writes:
> 
> > In article <[EMAIL PROTECTED]>,
> >     Rafael Garcia-Suarez <[EMAIL PROTECTED]> writes:
> > > Ok, select($$$$) now returns undef on error as of change #24223.
> > 
> > /me raises the backward compatibility police card
> > 
> > For what it's worth, I think this is a bad idea.
> 
> I can agree that it is a bad idea unless it can be demonstrated that a
> majority of usages of this function assumed undef on error.
> Fortunately we do have CPAN that can be used to do some statistical
> analysis of its usage.  I don't think we should keep this change until
> somebody that care enough do this analysis.  I assume this change is
> an experiment by Rafael to figure out how many would scream up about
> such a change.  I'm surprised by how few do.
> 
> > First of all it basically breaks the error handling in all my
> > select() code where I typically do something like:
> > 
> >  if (select(..) >= 0) {
> >      play a bit with time and handles, i don't really care what the exact
> >      number that got returned is
> >  } elsif ($! == EINTR) {
> >      redo some loop;
> >  } else {
> >      die "Unexpectedd select failure: $!"
> >  }
> > 
> > So now I'll get pointless undef warnings in the failure case and will
> > never get to the die even if I want it to.
> 
> So, how did you figure out this was the right way?  Did you read the
> source code for pp_sselect, did you find this by experimentation or
> was this just the obvious mapping to you?
> 
> I know I got it wrong because it was "obvious" to me that select
> worked like sysread, which is a function you will almost always use
> together with select.
> 
> > So it DOES break existing code.
> 
> It sure does.
> 
> > And fixing it so it works on *both* versions of perl gets messy too.
> 
> I don't know anything better than:
> 
>    my $nfound = select(...);

for backward compatibility you'd need the opposite
     $nfound //= -1;
err ... (ok, bad pun)
     defined $nfound or $nfound = -1;

otherwise you'd get an undef warning on this:
>    $nfound = undef if $nfound == -1;
>    if (defined $nfound) {
>        # play a bit with time and handles
>    }
>    else {
>        # failed; check $!
>    }
> 
> or make a wrapper for select that does this.
> 
> > Also notice that there are other calls in perl that do the -1 on failure,
> > see tell(), waitpid(), wait(), syscall(). So it isn't as if it happens
> > nowhere else in perl.
> 
> Seems to kill the consistency with sysread argument. There is no way
> we can get consistency between the various builtin functions anyway so
> why try.

-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using Perl 5.6.2, 5.8.0, 5.8.5, & 5.9.2  on HP-UX 10.20, 11.00 & 11.11,
 AIX 4.3 & 5.2, SuSE 9.1 & 9.2, and Cygwin. http://www.cmve.net/~merijn
Smoking perl: http://www.test-smoke.org,    perl QA: http://qa.perl.org
 reports  to: [EMAIL PROTECTED],                [email protected]

Reply via email to