Skip to content

Instantly share code, notes, and snippets.

pmichaud@kiwi:~/p6/rakudobrew$ rakudobrew build panda
Cloning into 'panda'...
remote: Counting objects: 3577, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 3577 (delta 2), reused 0 (delta 0), pack-reused 3567
Receiving objects: 100% (3577/3577), 600.22 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1531/1531), done.
Checking connectivity... done.
Already up-to-date.
===SORRY!===
@pmichaud
pmichaud / gist:05a986a0aa5bb6c16d3c
Created February 4, 2015 19:22
Suspending Rakudo support for Parrot (draft)
Suspending Rakudo support for Parrot
This past weekend at FOSDEM 2015, Larry announced that there will likely
be a Perl 6 release candidate in 2015, possibly around the September
timeframe. What we're aiming for is concurrent publication of a
language specification that has been implemented and tested in at least
one usable compilation environment -- i.e., Rakudo Perl 6.
So, for the rest of 2015, we can expect the Rakudo development team to
be highly focused on doing only those things needed to prepare for the
@pmichaud
pmichaud / gist:460bc17afcc5ca93b6b1
Last active August 29, 2015 14:07
APW2014 GLR discussion highlight summary
Since I know many people are eager for it, here's a very brief summary of GLR-related
decisions and accomplishments from #apw2014. In the next 2..3 days I plan to create
blog posts with much greater discussion of each. If any seem particularly confusing
or troubling to you, perhaps wait for the blog post(s) before panicking. :-)
* flattening rules have been revised somewhat
+ list assignment and array constructor continue to flatten their arguments (no change)
+ for (args) { ... } flattens args (no change)
+ .[] never flattens its invocant (consistency, capability, and performance wins)
+ function calls tend to flatten their arguments (e.g. "sort", "map", "pick")
@pmichaud
pmichaud / gist:55a0a1543a4fd8a17d7c
Last active August 29, 2015 14:07
IO::Handle .ins bug
pmichaud@plum:~/p6/rakudo$ cat ins.p6
my $fh = open("README.md");
for $fh.lines() {
say $fh.ins;
last;
}
pmichaud@plum:~/p6/rakudo$ ./perl6 ins.p6
pmichaud@kiwi:~/p6/nqp$ cat pipe1.pir
.sub 'main' :main
$P0 = new ['Env']
$P0['AAAAAA'] = 'ZZZZZZ'
$P1 = new ['FileHandle']
$P1.'open'("echo $AAAAAA", "wp")
$P1.'close'()
.end
pmichaud@kiwi:~/p6/nqp$ install/bin/parrot pipe1.pir
pmichaud@plum:~$ cat x.pl
#!/usr/bin/perl
my @a = 1..10;
foreach (grep { $_ % 2 } @a) { $_++; }
print "@a\n";
pmichaud@plum:~$ perl x.pl
pmichaud@kiwi:~/p6/rakudo$ ./perl6
> my $h = Hash[Str,Int].new;
().hash
> $h{3} = 'hello'; # okay
hello
> $h{'hello'} = 'hello'; # fails key check
Nominal type check failed for parameter 'key'; expected Int but got Str instead
> $h{4} = 15; # fails value check
Type check failed in assignment to '$v'; expected 'Str' but got 'Int'
sub foo {
state @ENDS;
my $foo = 'foo';
mkdir $foo;
@ENDS.push: { rmdir $foo };
END { .() for @ENDS }
}
pmichaud@kiwi:~/p6/rakudo$ cat rcx.p6
sub table ($base,$power) {
my $digits = ($base ** $power).chars;
printf "%{$digits}s lsb msb\n", 'number';
for ^$power {
my $x = $base ** $_;
printf "%{$digits}d %2d %2d\n", $x, $x.lsb, $x.msb;
}
}
sub msb(Int $self) {
return Nil if $self == 0;
return 0 if $self == -1;
my $msb = 0;
my $x = $self;
$x = ($x + 1) * -2 if $x < 0; # handle negative conversions
while $x > 0xff { $msb += 8; $x +>= 8; }
if $x > 0x0f { $msb += 4; $x +>= 4; }
if $x +& 0x8 { $msb += 3; }
elsif $x +& 0x4 { $msb += 2; }