Skip to content

Instantly share code, notes, and snippets.

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');
#!/usr/bin/env perl6
use v6;
role FooeyRole {
method bar {
say "stub soon";
!!!
}
}
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]);
}
}
@peschwa
peschwa / platin.p6
Last active October 30, 2015 05:27 — forked from MadcapJake/platin.p6
Translate English to Pig Latin with ease!
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 }
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;
});
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