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

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

From:
jonathan
Date:
December 9, 2008 06:12
Subject:
[svn:parrot] r33710 - trunk/languages/perl6/src/classes
Message ID:
20081209141205.0BEABCB9AF@x12.develooper.com
Author: jonathan
Date: Tue Dec  9 06:12:00 2008
New Revision: 33710

Modified:
   trunk/languages/perl6/src/classes/IO.pir

Log:
[rakudo] Implement auto-chomping, as mentioned in S29.

Modified: trunk/languages/perl6/src/classes/IO.pir
==============================================================================
--- trunk/languages/perl6/src/classes/IO.pir	(original)
+++ trunk/languages/perl6/src/classes/IO.pir	Tue Dec  9 06:12:00 2008
@@ -36,13 +36,15 @@
 =cut
 
 .sub 'lines' :method :multi('IO')
-    .local pmc PIO, res
+    .local pmc PIO, res, chomper
     PIO = getattribute self, "$!PIO"
     res = new 'List'
+    chomper = get_hll_global 'chomp'
 
   loop:
     $S0 = PIO.'readline'()
     unless $S0 goto done
+    $S0 = chomper($S0)
     res.'push'($S0)
     goto loop
 
@@ -113,10 +115,11 @@
 =cut
 
 .sub 'readline' :method
-    .local pmc PIO
+    .local pmc PIO, chomper
     PIO = getattribute self, "$!PIO"
     $P0 = PIO.'readline'()
-    .return ($P0)
+    chomper = get_hll_global 'chomp'
+    .tailcall chomper($P0)
 .end
 
 
@@ -222,22 +225,25 @@
 .end
 
 .sub 'item' :method :vtable('shift_pmc')
-    .local pmc pio
+    .local pmc pio, chomper
     $P0 = getattribute self, "$!IO"
     pio = getattribute $P0, "$!PIO"
     $P0 = pio.'readline'()
-    .return($P0)
+    chomper = get_hll_global 'chomp'
+    .tailcall chomper($P0)
 .end
 
 .sub 'list' :method
-    .local pmc pio, res
+    .local pmc pio, res, chomper
     $P0 = getattribute self, "$!IO"
     pio = getattribute $P0, "$!PIO"
     res = new 'List'
+    chomper = get_hll_global 'chomp'
 
   loop:
     $S0 = pio.'readline'()
     if $S0 == '' goto done
+    $S0 = chomper($S0)
     res.'push'($S0)
     goto loop
 



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