Hacker News new | past | comments | ask | show | jobs | submit login

Also:

  react { whenever }	# Code runs when a condition is met. 
I can only think this must be a generic https://en.wikipedia.org/wiki/COMEFROM. It is sure going to create some viciously subtle bugs.




From 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!";
    }
  }


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.


INTERCAL finally weeps for joy at being able to claim Perl 6 as a spiritual descendant.


Nice to know I'm not the only one who thought that. Now they just need the PLEASE keyword.


That construct reminds me most of callbacks: you define some code, and register it to be called in certain circumstances.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: