Four years ago November appeared. I’ve tried to use it. It simply doesn’t work today - Makefile tries to precompile Digest before Digest::SHA causing error (by the way, this module is called Digest::SHA256 when I’ve wrote this post, and it’s likely that it will change name to Sum::SHA256 in future and will use interface of other Sum:: namespace modules).
glitchmr@strawberry ~/g/november> env PERL6LIB=lib make
perl6 --target=pir --output=lib/Digest.pir lib/Digest.pm
===SORRY!===
When pre-compiling a module, its dependencies must be pre-compiled first.
Please pre-compile lib/Digest/SHA.pm
make: *** [lib/Digest.pir] Error 1
You would think that compiling Digest::SHA manually would solve the problem? Technically yes, but…
glitchmr@strawberry ~/g/november> perl6 --target=pir \
--output=lib/Digest/SHA.pir \
lib/Digest/SHA.pm
===SORRY!===
pir::load_bytecode missing a signature
So, what’s wrong with Digest::SHA. Well, that was its source.
class Digest::SHA:auth<thou>:ver<0.01> {
pir::load_bytecode('Digest/sha256.pbc');
multi method sha256_hex (Str $str) {
my $sha256_hex = Q:PIR {
.local pmc f, g, str
str = find_lex '$str'
f = get_root_global ['parrot'; 'Digest'], '_sha256sum'
$P1 = f(str)
g = get_root_global ['parrot'; 'Digest'], '_sha256_hex'
$S0 = g($P1)
%r = box $S0
};
return $sha256_hex;
}
multi method sha256_hex (@strs) {
return self.sha256_hex(@strs.join(""));
}
}
As you can notice, it depends on Digest/sha256.pbc from Parrot. Because of that, this module is Rakudo specific, but in this case it doesn’t matter much (perl6 is Rakudo).
What is the problem? Well, error message explains it - in Rakudo, you have to specify types of input and output every time you call any Parrot function directly. Why it was working before? Well, Rakudo didn’t required you to specify types before, but now it does (Why? I have no idea, NQP doesn’t require you to specify signature in this case). Anyways, the fix would be to type pir::load_bytecode__vS instead (v means void return and S means boxed string as argument).
I could try continuing, but that would be waste of time - November is simply old. The source code is unlikely to work in current Rakudo version (current Rakudo version is simply too modern for November to work).
It’s not just November, many modules in modules list simply won’t work in newest Rakudo version. This is normal - authors are simply too lazy to update their modules or they don’t work on those anymore (by the way, if you’re interested, make a fork of one of those modules, fix them and send pull request - even small help is good for Perl 6 community).
Why? Well, Perl 6 Synopsis is changing to improve language. Most of those changes are minor and usually wouldn’t break any program that wouldn’t try to detect those changes. But in certain cases, Synopsis needs bigger chances which could break more complex programs (Perl 6 is still in development, sometimes design is just wrong enough to justify breaking backwards compatibility). Also, Rakudo developers took lesson from this breakage - since 2012.07 every incompatibility is mentioned.