# New Ticket Created by  Siddhant Saraf 
# Please include the string:  [perl #113026]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=113026 >


$ perl6 -v
This is perl6 version 2012.05-15-gdca0fa6 built on parrot 4.4.0
revision RELEASE_4_4_0

<sisar> so here is the same code in perl6 and python:
https://gist.github.com/2762953. While the perl6 the loop terminates,
in pyhton it is an infinite loop. Though both behaviour have their
reasons, I can't decide which is better.
<sisar> why python's behaviour is logical, perl6's behaviour is trying
to prevent one from potentially infinite loops
...
<sisar> so, perl6 makes a temporary copy of @array before it even
starts looping. Why ?
...
<flussence> it counts the array then iterates over it
...
<flussence> copying every array just to loop over it would be crazy
inefficient, I think only PHP does that (and only because it uses copy
on write)
<sisar> flussence: what are merits of that, counting before iterating ?
<sisar> flussence: aye, making a copy would be super inefficient.
<flussence> if you have an SQL result pretending to be an array, you
don't want it going off and calling a .count that does "select
count(*)" on every iteration
<sisar> flussence: i'm sorry i'm not familiar with SQL
<geekosaur> don't worry about it.  point is that an array might not be
an array, it might be a big chunk of code pretending to be an array
<geekosaur> and you don't want to hammer that big chunk of code pointlessly
<flussence> it'd be like calling strlen() in C on a really big string
...
<TimToady> the whole point of lazy lists is that you never ask for the
size of something you're iterating over if you can help it
<TimToady> and I think an array iterator should be able to track a
growing array without snapshotting the old length
<flussence> that makes sense, but I can't imagine it being fun to implement :)
...
<sisar> TimToady: so it is a genuine bug? fwiw, both niecza and rakudo
iterate only twice.
<TimToady> I think so

Reply via email to