Hasty Briefsbeta

Bilingual

Generators in Lone Lisp

3 days ago
  • #lone-lisp
  • #iteration
  • #generators
  • Lone Lisp introduces a dedicated generator type to simplify iteration.
  • Generators, or semicoroutines, yield values back to their callers without the complexity of full coroutines.
  • Delimited continuations were considered but rejected due to performance overhead from stack copying.
  • Generators avoid stack copying by using separate stacks that can be swapped in and out.
  • The implementation involves sanity checks, stack swapping, and handling generator starts and resumes.
  • The `generator` primitive creates generator values, while `yield` handles value production and stack management.
  • Generators provide a foundation for efficient iteration, supporting loops and infinite lists.