perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] last call for $filter->read
Date Wed, 02 Jun 2004 06:06:00 GMT
Stas Bekman wrote:
> I think this is the last function in the read() family that needs 
> tweaking (currently most errors are silently ignored). I've changed the 
> API to be consistent with the rest of modperl 2.0 read functions, and 
> the only added inconvenience is that you need to add defined inside 
> while call. So instead of writing:
> 
>     while ($filter->read(my $buffer, $wanted)) {
>         $filter->print($buffer);
>     }
> 
> You will write:
> 
>     while (defined(my $buffer = $filter->read($wanted))) {
>         $filter->print($buffer);
>     }
> 
> The existing API is badly broken, since there is no way to break the 
> while loop in case of an error. It was working perfectly when there are 
> no errors.
> 
> Errors are now checked internally and exceptions are thrown if anything 
> goes wrong.
> 
> I've adjusted all the tests and they all pass fine. Let me know if you 
> have any problem with that change.

Or may be we should keep it as is and just fix the error handling.

     while ($filter->read(my $buffer, $wanted)) {
         $filter->print($buffer);
     }

is still easier to write... and if you forget the defined() part you may get 
errors when you get "0" as a returned string (which luckily one of the tests 
has happened to do).

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message