Skip to content

WIP: Fix loop function transform

commit e6489e09 switched from using with to using functions which caused breakage, as var statements are local to functions, but not with blocks. In addition the break statement is function-local

this change:

  • Hoists non-temporary var statements outside of loop body, and use setf instead of var inside the loop body [1]

  • Switch from using (break) to using (return-from), so that loop bodies converted to anonymous functions behave properly

1: This does change PS:LOOP to be more like CL:LOOP in a confusing way:

(loop for i from 1 to 10 collect (lambda () i)) will return functions that all return 11, rather than functions that return values from 1..10

Merge request reports