问题
#!perl6
use v6;
my $message = "\nHello!\n\nSleep\nTest\n\n";
my @a = $message.split( '' );
for @a {
sleep 0.3;
.print;
}
Does perl6 enable "autoflush" by default. With perl5 without enabling "outflush" I don't get this behavior.
回答1:
Rakudo enables autoflush by default; the specification is silent about the default.
回答2:
Quoting from the docs regarding auto flush:
‘No global alternative available. TTY handles are unbuffered by default, for others, set out-buffer to zero or use :!out-buffer with open on a specific IO::Handle.’
So any printing to stdout is unbuffered and I guess would behave similar to auto flushed stdout of perl5.
Other handles depend on the out-buffer size set.
来源:https://stackoverflow.com/questions/5056085/perl6-rakudo-does-perl6-enable-autoflush-by-default