@@ -296,6 +296,37 @@ scalar container elements, not just the values.
296
296
(1..3) ⟛ @a # (1..3, @a[0], @a[1], @a[2])
297
297
(1, 2, 3) ⟛ @a # (1, 2, 3, @a[0], @a[1], @a[2])
298
298
299
+ =item *
300
+
301
+ The pre-GLR implementation of lists uses "immutable iterators",
302
+ which address the problem of lazy lists becoming bound to more
303
+ than one variable or structure. However, the current implementation
304
+ keeps the iteration sequence as a linked list, and relies on the VM
305
+ being able to GC any parts of the iteration sequence that are no
306
+ longer needed. In practice this doesn't work out so well, as any
307
+ VM-level register (temporary, lexical C<self>, routine parameter, etc.)
308
+ pointing to an early part of the iteration sequence ends up keeping the
309
+ entire list alive in memory until the current loop operation has
310
+ fully completed. In other words, processing a million line file ends
311
+ up with all of the lines in memory before they're GC'd.
312
+
313
+ Post-GLR, the list implementation needs to actively manage the
314
+ iteration sequences somehow, and not rely solely on the VM to
315
+ timely clear all of its internal references to long data structure
316
+ chains. In short, iterators may end up being mutable again. If
317
+ that's the case we have to figure out how to deal with iterators
318
+ being shared among multiple lists. This may involve maintaining
319
+ "binding counts", or some sort of other sharing/duplication
320
+ mechanism in the lazy list generation system.
321
+
322
+ If "binding counts" sounds a lot like "reference counts" to you...
323
+ you're correct, it is. And it potentially has all of the drawbacks
324
+ that reference counting brings with it. However, at least in this
325
+ case the number of ways that binding takes place (i.e., through the
326
+ binder) is somewhat limited. I'm hoping to avoid this, but Jonathan
327
+ and I know where the key components are if it turns out to be
328
+ necessary.
329
+
299
330
=back
300
331
301
332
=head1 AUTHORS
0 commit comments