develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34011 - trunk/languages/perl6/src/classes

From:
pmichaud
Date:
December 16, 2008 20:30
Subject:
[svn:parrot] r34011 - trunk/languages/perl6/src/classes
Message ID:
20081217043013.AA8D9CBA12@x12.develooper.com
Author: pmichaud
Date: Tue Dec 16 20:30:12 2008
New Revision: 34011

Modified:
   trunk/languages/perl6/src/classes/Int.pir
   trunk/languages/perl6/src/classes/Num.pir
   trunk/languages/perl6/src/classes/Str.pir

Log:
[rakudo]:  Add .pred and .succ methods for Int/Str/Num (RT #61420)
* Patch courtesy Eric Hodges <eric.hodges@gmail.com>


Modified: trunk/languages/perl6/src/classes/Int.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Int.pir	(original)
+++ trunk/languages/perl6/src/classes/Int.pir	Tue Dec 16 20:30:12 2008
@@ -37,6 +37,12 @@
 .end
 
 
+.sub 'abs' :method :multi('Integer')
+    $P0 = n_abs self
+    .return ($P0)
+.end
+
+
 =item ACCEPTS()
 
 =cut
@@ -47,6 +53,7 @@
 .end
 
 
+
 =item perl()
 
 Returns a Perl representation of the Int.
@@ -59,8 +66,21 @@
 .end
 
 
-.sub 'abs' :method :multi('Integer')
-    $P0 = n_abs self
+=item succ and pred
+
+Increment and Decrement Methods
+
+=cut
+
+.sub 'pred' :method
+    $P0 = clone self
+    dec $P0
+    .return ($P0)
+.end
+
+.sub 'succ' :method
+    $P0 = clone self
+    inc $P0
     .return ($P0)
 .end
 

Modified: trunk/languages/perl6/src/classes/Num.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Num.pir	(original)
+++ trunk/languages/perl6/src/classes/Num.pir	Tue Dec 16 20:30:12 2008
@@ -67,6 +67,25 @@
 .end
 
 
+=item succ and pred
+
+Increment and Decrement Methods
+
+=cut
+
+.sub 'pred' :method
+    $P0 = clone self
+    dec $P0
+    .return ($P0)
+.end
+
+.sub 'succ' :method
+    $P0 = clone self
+    inc $P0
+    .return ($P0)
+.end
+
+
 =item WHICH()
 
 Returns the identify value.

Modified: trunk/languages/perl6/src/classes/Str.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Str.pir	(original)
+++ trunk/languages/perl6/src/classes/Str.pir	Tue Dec 16 20:30:12 2008
@@ -113,6 +113,24 @@
     .return ($P0)
 .end
 
+=item succ and pred
+
+Increment and Decrement Methods
+
+=cut
+
+.sub 'pred' :method
+    $P0 = clone self
+    dec $P0
+    .return ($P0)
+.end
+
+.sub 'succ' :method
+    $P0 = clone self
+    inc $P0
+    .return ($P0)
+.end
+
 
 =item WHICH()
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About