This file contains hidden or 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 nqp; | |
use QRegex:from<NQP>; | |
BEGIN { | |
nqp::bindkey( | |
%*LANG, "MAIN", %*LANG<MAIN>.HOW.mixin(%*LANG<MAIN>, role { | |
token quote:sym<emote> { | |
"✌" ~ "✌" | |
{ | |
my $shared := nqp::getattr(nqp::decont($/.CURSOR), Cursor, '$!shared'); |
This file contains hidden or 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
#!/usr/bin/env perl6 | |
use v6; | |
role FooeyRole { | |
method bar { | |
say "stub soon"; | |
!!! | |
} | |
} |
This file contains hidden or 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 v6; | |
role Signal { | |
has @.slots; # a nice list of callbacks (that are methods) | |
multi method connect(Any:D $rcpt, Method $method){ | |
@.slots.push([self, $rcpt, $method]); | |
} | |
} |
This file contains hidden or 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
multi MAIN($arg where *.IO.f) { | |
say translate($arg.IO.slurp).Str | |
} | |
multi MAIN($arg) { | |
say translate($arg).Str | |
} | |
sub translate(Str:D $english) { $english.words.map: &translate-word } |
This file contains hidden or 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 v6; | |
role WriteOnce { | |
method compose($pkg) { | |
callsame; | |
$pkg.^find_method(self.name.substr(2)).wrap(-> $obj { | |
die "Cannot assign more than once to a writeonce attribute" | |
if self.get_value($obj).defined; | |
callsame; | |
}); |
This file contains hidden or 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
our $count = 0; | |
class MagicVal { | |
has Int $.constant; | |
has Int $.varies = 0; | |
method varies is rw { | |
$count++; | |
return-rw Proxy.new( | |
# note that FETCH and STORE cannot go through the accessors |