Created
August 24, 2010 21:09
-
-
Save masak/548328 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
use Remember; | |
todo { | |
remember "to buy milk"; | |
remember "to make toys for my pet dragons"; | |
remember "to stop by the gen-eng shop and pick up the 10 foot butterfly"; | |
} | |
remember "to only remember things in todo blocks"; # warn: can't remember outside todo | |
.say for todo-list() # milk, toys, butterfly | |
# ... and this is all the module code that's needed: | |
module Remember; | |
my @todo-list; | |
sub todo-list() is export { @todo-list } | |
sub remember(*@_) is export { | |
try { | |
&*remember(@_); | |
} | |
if $! { | |
warn "Can't remember outside of todo"; | |
} | |
} | |
sub todo(&code) is export { | |
my &*remember = -> *@_ { push @todo-list, [~] @_ }; | |
&code(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment