Skip to content

Instantly share code, notes, and snippets.

/test.pl Secret

Created December 28, 2012 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3dc5fb0153bf69a83c6d to your computer and use it in GitHub Desktop.
Save anonymous/3dc5fb0153bf69a83c6d to your computer and use it in GitHub Desktop.
use v6;
module MyApp {
class Foo {
has $.name;
has $.things = [];
method add_thing (Foo $thing) {
$.things.push($thing);
}
}
my $*dyn;
sub foo (Foo $thing, Callable $body) is export {
if $*dyn {
$*dyn.add_thing($thing);
}
$*dyn = $thing;
$body.();
return $thing;
}
}
import MyApp;
my $foo = foo MyApp::Foo.new(name => 'a'), {
foo MyApp::Foo.new(name => 'b'), sub {
};
foo MyApp::Foo.new(name => 'c'), {
foo MyApp::Foo.new(name => 'd'), sub {
};
};
};
say $foo.perl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment