Created
September 16, 2013 20:33
-
-
Save jnthn/6586219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\consulting\rakudo>perl6 -I. -MPrev | |
> 1 + 2 | |
3 | |
> 2 * prev | |
6 | |
> 3 * prev | |
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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