mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Using fold() and reduce() to compose objects creates deep call stacks
#285
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bioball on GitHub (Feb 21, 2025).
This code will stack overflow:
At the end of each iteration, the returned value from
adderretains a lazyvalue. The resulting object, as a result, has avaluemember that recurses.This type of code is less performant, and is also vulnerable to stack overflow exceptions. It's also very hard to understand why this is recursive. We should have some way to avoid deep call stacks here.
Note: a workaround is to force the computation with a
letexpression, e.g.