This is the same as in Smalltalk. There a loop is actually a method of a
Sequence which executes the code of the loop on each Sequence element. The
Sequence is only accessed through `first' and `next'. So it can also choose
to generate the next item only when requested. This sounds very clean to
You could also have a reverse loop when Sequences would have methods last
>I am beginning to like this solution. It would not be 100 percent
>compatible, since uses of range() in other contexts would work
>differently or not at all (e.g. you can't initialize a list with a
>range and then remove items from it) but those uses would be a far
Maybe when a range object is copied it should have a copy method, which
returns a real list with all elements.
Centre for Mathematics & Computer Science (CWI),
Kruislaan 413, 1098 SJ Amsterdam, The Netherlands.
Email:email@example.com, Tel: +31-20-592 4009