Deprecate times, while, and until combinators #273
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#273
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Summary
The
times,while, anduntilcombinators all require stack-neutral quotations ([..a -- ..a]). This limitation makes them nearly useless for real-world use cases.The Problem
Stack-neutral means the quotation must leave the stack in the same shape it found it. What operations are actually stack-neutral?
[1 i.+]- increment in place[dup i.*]- square a number[swap]- reorderWhat operations are NOT stack-neutral (the 90%+ of real use cases)?
[io.write-line]-(String --)- consumes a value[i.+]/[i.*]-(Int Int -- Int)- accumulation[drop]-(T --)- consuming[dup]-(T -- T T)- producing[list.push]- modifies listThe stack-neutral requirement is fundamental to how these combinators work - without knowing iteration count at compile time, the compiler can't allow the stack shape to change per iteration.
Proposed Solution
Deprecate all three combinators and encourage users to use:
list.fold,list.map,list.eachMigration Path
This is a breaking change. Use semantic versioning to signal this:
Rationale
Providing built-ins that only work for ~10% of use cases creates confusion. Users hit the stack-neutral limitation and wonder why their reasonable code doesn't compile. Teaching recursion and list processing as the primary patterns leads to more consistent, understandable code.
Related
UPDATE: we're completely removing these combinators in 1.1.0 since we found none of the large users of seq, seq-lisp, seq-actor, or seq-lisp-2 use them due to the limitations above.
https://github.com/navicore/patch-seq/pull/281