-
Notifications
You must be signed in to change notification settings - Fork 597
Description
Module: Time::HiRes
Description
hi, friends! it's me! i've come to discuss a most damning misbehavior.
Time::HiRes::sleep
takes more than one argument, which makes it incompatible with "core" sleep() and leads to unexpected behavior.
Steps to Reproduce
use Time::HiRes 'sleep'; # comment me to fix problem
$| = 1;
my $condition = 0;
while()
{
print '.';
sleep 1, next unless $condition;
}
Expected behavior
1 second sleep before before looping, as will happen with "core" sleep.
Perl configuration
lmk if you really want this, i don't think it's relevant since the bug happens exactly everywhere, because of being located in the Time::HiRes::sleep() sub.
pudding's two cents
ok so i understand that fixing this The Correct Way, so that Time::HiRes::sleep only takes a single argument like "core" sleep does, will effectively alter/break current behavior for software written the way mine and my example is, but i really insist that this is the necessary solution. we must not sweep this under the carpet by just changing the documentation to match the broken Time::HiRes::sleep, or insisting that we start wrapping everything in parentheses. the function only uses the first argument. it should only accept one argument. it should be syntactically compatible with "core" sleep().
i also want to shout out to my main man MAUKE on the libera IRC network for figuring this out.