Skip to content

Instantly share code, notes, and snippets.

View awwaiid's full-sized avatar

Brock Wilcox awwaiid

View GitHub Profile
class Template
def initialize(&block)
@body = block
end
def method_missing(v)
@params[v]
end
module Test::QuickCheck {
multi gen(Int) { 1000000.rand.Int }
our sub verify-one( &f, &predicate ) {
my @params = &f.signature.params.map: -> $p {
# say "Param: {$p.gist}";
gen($p.type)
};
# signal(SIGINT).tap: {
# note "Took { now - INIT now } seconds. $*THREAD";
# }
my $interrupt = signal(SIGINT);
$interrupt.tap: -> $v {
note "[got interrupt $v]";
}
sub catch-control {
CONTROL {
die "Caught a CONTROL ({.gist})";
}
die "forced exception";
}
for 1 {
catch-control;
sub no-catch-control {
die "no-catch-control exception";
}
sub catch-control {
CONTROL {
say "CONTROL: {$_.gist}";
die "control exception";
}
sub no-catch-control {
die "no-catch-control exception";
}
sub catch-control {
CONTROL {
say "CONTROL: {$_.gist}";
die "control exception";
}
> 5+5
10
> next
CONTROL: Died with CX::Next
EXCEPTION: control exception
in sub eval at simple-repl.p6 line 8
in block <unit> at simple-repl.p6 line 34
> last

Strange Loop talk proposal -- due 2016-05-09 http://thestrangeloop.com/cfp.html

Title: Rakudo/Perl6, The Polyglot Language

Abstract (max 1500 chars)

Taking multi-paradigm to a new level, Perl 6 goes far beyond its Perl 5 roots, adopting concepts from many languages. From Haskell/Elixir style typed multi-dispatch to Ruby style objects-all-the-way-down, you can pick a model that best fits your problem domain. Add to this some very practical innovations, such as a grammar engine and native stream/promise async/concurrency, and you have both a useful tool and an interesting experimentation platform. The production-ready Rakudo implementation of Perl 6 targets both its own MoarVM and the JVM, and a JS target is in progress!

Strange Loop talk proposal -- due 2016-05-09
http://thestrangeloop.com/cfp.html
Title: Rakudo/Perl6, The Polyglot Langauge
Abstract (max 1500 chars)
========
Taking multi-paradigm to a new level, Perl 6 goes far beyond it's Perl 5 roots, adopting concepts from many languages. From Haskell/Elixir style typed multi-dispatch to Ruby style objects-all-the-way-down, you can pick a model that best fits your problem domain. Add to this some very practical innovations, such as a grammar engine and native stream/promise async/concurrency, and you have both a useful tool and an interesting experimention platform. The production-ready Rakudo implementation of Perl 6 targets both it's own MoarVM and the JVM, and a JS target is in progress!
say "hello";
subset Natural of Int where * > -1;
# Using a given/when (like a case statement)
sub conv1(Natural $x) {
given $x {
when 0 { "0" }
when 1 { "1" }
when * %% 2 { conv1($x div 2) ~ "0" }