I'm doing yet another tweak on the read() API to make things really consistent:
So now we (will) have the following read functions:
- APR::Socket:
$len = $socket->read(my $buffer);
- APR::Bucket:
$len = $bucket->read(my $buffer);
- APR::Filter:
$len = $filter->read(my $buffer);
(plus all the optional arguments as before)
as you can see they now all function indentically and they are much easier to use, even though you pass $buffer by reference.
The last change required you to write this kind of code (not very suitable for conditionals)
my $buffer = $x->read();
if (length $buffer) {
...
}sure you could do
if (length(my $buffer = $x->read()) {
...
}but the problem is that most people will forget the length() part, since most of the time it'll work without it. But once you get "0" returned that will suddently fail.
So using the new API, you just write:
if ($x->read(my $buffer)) { ... }or:
while($x->read(my $buffer)) { ... }similar to how streaming filter idiom works:
while ($filter->read(my $buffer)) { $filter->print(lc $buffer) }I think one more function that needs to be changed is APR::Brigade::flatten, since it's really a read() function. So I propose:
$len = $bb->flatten(my $buffer, ...);
What do you think?
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
