RFC: Auxiliary stash stacks for complex stack juggling #350
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#350
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
Should Seq support auxiliary "stash" stacks for temporary storage during complex stack manipulation?
Background
Classic Forth provides multiple stacks - the data stack, return stack, and sometimes separate numeric stacks. The return stack (
>R/R>) is commonly used for temporary storage when stack juggling gets unwieldy.This issue explores whether Seq would benefit from similar functionality, and what the design constraints should be.
Proposed Design
Stash Stacks (not execution stacks)
The key distinction: auxiliary stacks would be storage only, not execution contexts.
Generators already handle the "suspended execution with arbitrary stack state" use case. Stash stacks would purely be for juggling convenience.
Scoped and Balanced
Auxiliary stacks must be empty when a word returns - enforced by the compiler:
Single vs Named Stacks
Option A: Single auxiliary stack (simpler)
Option B: Named stacks (more flexible)
Named stacks would need scoping rules - probably lexical scope tied to word boundaries.
The Philosophical Question
Arguments Against (purity)
Concatenative languages derive power from having the stack as the entire program state. Every word is
Stack → Stack. Stash stacks introduce hidden state:This is the same problem with variables that concatenative languages avoid. It breaks equational reasoning.
Arguments For (pragmatism)
>R/R>has existed since the beginning>auxis( a -- ),aux>is( -- a ), they compose like any wordletbindingsComparison to
letbindingsletbindingxrefers to valueStash stacks are arguably less of a deviation than
letbecause they're still operations, not bindings.Open Questions
Related
>R,R>,R@)Captured from design discussion. No immediate action needed - for future consideration.
https://github.com/navicore/patch-seq/pull/352