New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Range reusing. #121
Comments
From @bacekHello. This is fix for reusing same range many times. my $a = (1..5); say $a.from; my @b = $a; say 'One ' Produces: Patch is partially useful even for (future) lazy lists. -- |
From @bacekInline Patchdiff --git a/languages/perl6/src/classes/Range.pir b/languages/perl6/src/classes/Range.pir
index ecd24ca..f0670ee 100644
--- a/languages/perl6/src/classes/Range.pir
+++ b/languages/perl6/src/classes/Range.pir
@@ -53,11 +53,12 @@ we need to not do that.
=cut
.sub 'list' :method
- .local pmc res, cur_val
+ .local pmc res, cur_val, it
+ it = iter self
res = new 'List'
it_loop:
- unless self goto it_loop_end
- cur_val = shift self
+ unless it goto it_loop_end
+ cur_val = shift it
push res, cur_val
goto it_loop
it_loop_end:
@@ -114,12 +115,18 @@ Returns a Perl code representation of the range.
=item get_iter (vtable)
-Just returns this Range itself, since a Range is an iterator.
+Clone this Range itself, since a Range is an iterator.
=cut
.sub get_iter :method :vtable
- .return (self)
+ .local pmc from, to, retv
+ $P0 = self.'from'()
+ from = clone $P0
+ $P0 = self.'to'()
+ to = clone $P0
+ retv = 'infix:..'(from, to)
+ .return(retv)
.end
|
From @bacekOn Fri Jun 06 01:07:56 2008, bacek wrote:
New version of fix after jonathan comments. -- |
From @bacek |
@bacek - Status changed from 'new' to 'open' |
From @pmichaudApplied (with minor mods) in r28129. Thanks! Pm |
1 similar comment
From @pmichaudApplied (with minor mods) in r28129. Thanks! Pm |
@pmichaud - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#55400 (status was 'resolved')
Searchable as RT55400$
The text was updated successfully, but these errors were encountered: