5 ms·
> ++; # An anonymous state variable, for very fast loops Perl, never stop being you
by thedz 11y ago
> ++; # An anonymous state variable, for very fast loops
Perl, never stop being you
- cygx 11y agoIf I'm not mistaken, that probaby should have read $++;
- hoodoof 11y agoThis. This thread right here is the magic of Perl.
- deleted 11y ago[deleted]
- stone-monkey 11y agoI also attended the unveiling yesterday; If I remember correctly, I'm about 95% sure your assumption is correct.
- labster 11y agoCorrect. $ 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 http://rosettacode.org/wiki/Mad_Libs#Perl_6
- inopinatus 11y agoAlso: react { whenever } # Code runs when a condition is met. I can only think this must be a generic https://en.wikipedia.org/wiki/COMEFROM https://en.wikipedia.org/wiki/COMEFROM. It is sure going to create some viciously subtle bugs.
- cygx 11y agoCf http://www.jnthn.net/papers/2015-spw-concurrency.pdf http://www.jnthn.net/papers/2015-spw-concurrency.pdf
- raiph 11y agoFrom pages 56 and 57: > 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: react { whenever $code -> $path { say "Code file $path changed!"; } }
- btown 11y agoThis 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.
- cstross 11y agoINTERCAL finally weeps for joy at being able to claim Perl 6 as a spiritual descendant.
- meepmorp 11y agoNice to know I'm not the only one who thought that. Now they just need the PLEASE keyword.
- _delirium 11y agoThat construct reminds me most of callbacks: you define some code, and register it to be called in certain circumstances.
- kbenson 11y agoOne 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. 1: http://design.perl6.org/S04.html#Phasers http://design.perl6.org/S04.html#Phasers 2: http://design.perl6.org/S04.html#Exception_handlers http://design.perl6.org/S04.html#Exception_handlers