From: "Patrick R. Michaud" <[EMAIL PROTECTED]>
   Date: Sat, 4 Oct 2008 09:41:22 -0500

   On Fri, Oct 03, 2008 at 09:47:38PM -0700, Larry Wall wrote:
   > On Fri, Oct 03, 2008 at 11:57:30PM -0400, Michael G Schwern wrote:
   > : What's the status of numeric upgrades in Perl 6?  Is see the 
   > : docs say "Perl 6 intrinsically supports big integers and rationals 
   > : through its system of type declarations. Int automatically 
   > : supports promotion to arbitrary precision" but it looks like it's 
   > : doing the same thing as Perl 5.
   > 
   > The status of numeric upgrades in Perl 6 is fine.  It's rakudo that
   > doesn't do so well.  :)

   Correct.  I suspect that eventually the Rakudo developers will have
   to develop a custom set of PMCs for Perl 6 behaviors rather than
   relying on the Parrot ones.

The Parrot behavior in this case may be closer than you think.  After
applying the patch below, I get the expected output from Rakudo:

        [EMAIL PROTECTED]> ./perl6 -e 'say 2**40'
        1099511627776
        [EMAIL PROTECTED]> ./perl6 -e 'say 2**50'
        1125899906842624
        [EMAIL PROTECTED]> ./perl6 -e 'say 2**1100'
        
13582985290493858492773514283592667786034938469317445497485196697278130927542418487205392083207560592298578262953847383475038725543234929971155548342800628721885763499406390331782864144164680730766837160526223176512798435772129956553355286032203080380775759732320198985094884004069116123084147875437183658467465148948790552744165376
        [EMAIL PROTECTED]> 

It does produces >300 spectest_regression failures, though, so I don't
claim the patch is right.

   Parrot doesn't currently downgrade BigInt PMCs to Integer when it
should, though.

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/

Make <infix:**> and <infix:*> DTRT for Int => BigInt promotion.  May
break other numeric behaviors.

Index: languages/perl6/src/builtins/op.pir
===================================================================
--- languages/perl6/src/builtins/op.pir (revision 31592)
+++ languages/perl6/src/builtins/op.pir (working copy)
@@ -59,21 +59,12 @@
 
 ## exponentiation
 .sub 'infix:**' :multi(_,_)
-    .param num base
-    .param num exp
-    $N0 = pow base, exp
-    .return ($N0)
+    .param pmc base
+    .param pmc exp
+    $P0 = n_pow base, exp
+    .return ($P0)
 .end
 
-
-.sub 'infix:**' :multi(Integer,Integer)
-    .param num base
-    .param num exp
-    $N0 = pow base, exp
-    .return '!upgrade_to_num_if_needed'($N0)
-.end
-
-
 ## symbolic unary
 .sub 'prefix:!' :multi(_)
     .param pmc a
@@ -140,21 +131,13 @@
 
 ## multiplicative
 .sub 'infix:*' :multi(_,_)
-    .param num a
-    .param num b
-    $N0 = a * b
-    .return ($N0)
+    .param pmc a
+    .param pmc b
+    $P0 = n_mul a, b
+    .return ($P0)
 .end
 
 
-.sub 'infix:*' :multi(Integer,Integer)
-    .param num a
-    .param num b
-    $N0 = a * b
-    .return '!upgrade_to_num_if_needed'($N0)
-.end
-
-
 .sub 'infix:/' :multi(_,_)
     .param num a
     .param num b

Reply via email to