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
SAD.pm: | |
use SAD::Special; | |
class SAD { | |
has $!nothing; | |
} | |
SAD/Special.pm: | |
role SAD::Special { |
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
role foo { | |
my @.bar; | |
method addbar (*@new) { @.bar.push(@new) } | |
} | |
class bar does foo { | |
method BUILD { self.addbar('bar') } | |
} | |
class baz does foo { |
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
class fakehash { | |
has $.keys handles 'push'; | |
has $.calculator = { $^a }; | |
has $.null; | |
method postbrace ($lookup) { | |
$lookup ~~ $.keys.any ?? $!calculator($lookup) !! $.null; | |
} | |
} | |
sub postcircumfix:<{ }> (fakehash $bar, $lookup) { |
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
role SomeTrait { | |
method apply_handles($attr: Mu $pkg) { | |
say "apply_handles"; | |
my $name = $attr.name; | |
my $accessor = $name.subst(/^../, ''); | |
my $r = sub ($obj, |args) is rw { | |
say "$name accessor"; | |
nextsame; | |
}; | |
$pkg.HOW.find_method($pkg, $accessor).wrap($r); |
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
require 'pp' | |
module Xen | |
class VM < Base | |
# Creates a new VM with a certain name set and a amount of memory | |
# (in bytes) on a cluster | |
def self.create(template = nil, name = nil, memory = 32 * MB, | |
cluster = nil, varch = :hvm, boot_loader = nil, |