> Perl 6 has an asynchronous looping construct called whenever ... runs whenever a value arrives ... can live in a ... react block (works like entering an event loop)
my $code = supply {
whenever IO::Notification.watch-path($src-dir) {
emit .path if .path ~~ /<.pm .p6> $/;
}
}
So now, whenever something in $src-dir changes and its path ends with '.pm' or '.p6' that path will be emitted -- which in this case means it'll be pushed to any construct pulling from $code. Such as:
This is probably the most interesting link in this entire thread.
The "react" keyword is just a channel subscription, and inside it has a pattern matcher. Channels are first-class citizens, and you're encouraged to chain channels rather than falling into callback hell. It's like Go and Ruby had a child.
If anything piqued my interest in Perl 6, it was this.
One of my favorite new features is phasers[1] (loop flow control shortcuts), and as a subcomponent of that, how CATCH[2] is implemented as a phaser so it's within the block that had the error still has access to the variables in the same scope.
Correct. $ is an anonymous scalar (which autovivifies to 0 and increments in $++). There's also anonymous array @ and anon hash %. The hash form you can see in action here, in the one-liner mad-libs code: http://rosettacode.org/wiki/Mad_Libs#Perl_6
Perl, never stop being you