On Mon, 07 Jun 2010 02:11:05 +0200, Patrick R. Michaud
<[email protected]> wrote:
On Sun, Jun 06, 2010 at 11:06:07PM +0200, Cosimo Streppone wrote:
Hi all,
Just for fun, I'm trying to write a Digest::MD5 module for Rakudo.
Right now I'm stuck with something like:
[...]
The MD5.pbc module loads into a different HLL namespace from
Rakudo ('parrot' instead of 'perl6'). So, you probably want
'get_root_namespace' here.
sub test($text) {
Q:PIR {
load_bytecode 'Digest/MD5.pbc'
$P0 = find_lex '$text'
$P1 = get_root_global ['parrot'], '_md5sum'
$P2 = $P1($P0)
$P1 = get_root_global ['parrot'], '_md5_hex'
$S2 = $P1($P2)
say $S0
}
}
test('hello world');
I guess you meant 'say $S2'.
Running this program for me (with --trace=1) results in a
segmentation fault somewhere in the _md5sum function.
Interesting, because it doesn't segfault for me. I get:
NULL PMC access in find_method('signature')
in 'test' at line 2:test.pl
in main program body at line 15:test.pl
My ignorant guess is that the signature() method is
available in the 'parrot' namespace, but not in my
current namespace.
This makes me think I'd prefer avoiding the globals business
and using the functions in their natural package (Digest?),
but I don't know how to do that.
I tried:
- find_method ['Digest'], '_md5sum'
- get_hll_global ['Digest'], '_md5sum'
- other futile attempts...
with no luck.
--
Cosimo