From: Bob Rogers <[EMAIL PROTECTED]> Date: Sat, 4 Oct 2008 22:08:10 -0400
From: "Patrick R. Michaud" <[EMAIL PROTECTED]> Date: Sat, 4 Oct 2008 18:15:57 -0500 . . . All of the mechanisms I've been able to find in Parrot for converting an arbitrary PMC to a number seem to result in the code for infix:<*> that we have now. I'm open for suggestions to improve this, though. Pm Hmm. My instinct would be to rely on MMD . . . This exposes an MMD bug (it runs forever) . . . Wrong; Parrot was replacing my Integer with the FixedPMCArray. (Grr.) Here is an improvement: .sub 'infix:*' :multi(Perl6Array,_) .param pmc a .param pmc b $I0 = a $P0 = new 'Integer' $P0 = $I0 .return 'infix:*'($P0, b) .end .sub 'infix:*' :multi(_,Perl6Array) .param pmc a .param pmc b $I0 = b $P0 = new 'Integer' $P0 = $I0 .return 'infix:*'(a, $P0) .end It works for some cases: [EMAIL PROTECTED]> ../../perl6 -e 'my @a = <abc def ghi>; say @a * 483648;' 1450944 [EMAIL PROTECTED]> ../../perl6 -e 'my @a = <abc def ghi>; say 483648 * @a;' 1450944 [EMAIL PROTECTED]> ../../perl6 -e 'my @a = <abc def ghi>; say 483648 * 483648 * @a;' 701746163712 [EMAIL PROTECTED]> ../../perl6 -e 'my @a = <abc def ghi>; say 483648 * 483648 * 483648 * @a;' 339398128586981376 [EMAIL PROTECTED]> But not others: [EMAIL PROTECTED]> ../../perl6 -e 'my @a = <abc def ghi>; say @a * 2147483648;' -6442450944 [EMAIL PROTECTED]> ../../perl6 -e 'my @a = <abc def ghi>; say 2147483648 * @a;' get_bignum() not implemented in class 'Float' current instr.: 'infix:*' pc 16030 (src/gen_builtins.pir:10014) . . . -- Bob