Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created September 16, 2013 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jnthn/6586219 to your computer and use it in GitHub Desktop.
Save jnthn/6586219 to your computer and use it in GitHub Desktop.
C:\consulting\rakudo>perl6 -I. -MPrev
> 1 + 2
3
> 2 * prev
6
> 3 * prev
18
my Mu $prev;
sub prev() is export { $prev }
my $comp := nqp::getcomp('perl6');
$comp.HOW.add_method($comp, 'autoprint', method (Mu \value) {
$prev := value;
self.interactive_result(value)
unless nqp::tellfh(nqp::getstdout()) > $*AUTOPRINTPOS;
});
$comp.HOW.compose($comp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment