times: allow non-stack-neutral quotations when count is a literal #271
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#271
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
timescombinator currently requires stack-neutral quotations[..a -- ..a], which significantly limits its usefulness for common patterns.Current Behavior
The quotation
[i.*]has effect[Int Int -- Int](consumes 2, produces 1), which isn't stack-neutral, so it's rejected.Expected Behavior
When the count is a compile-time literal, the compiler should type-check the unrolled form:
This is perfectly typeable. The restriction to
[..a -- ..a]is only necessary when the count is a runtime value (where the final stack shape can't be statically determined).Use Cases That Don't Work Today
Use Cases That Do Work
Proposed Solution
In the typechecker, when
timeshas a literal count:[..a -- ..a]For runtime counts, keep the current
[..a -- ..a]requirement since the stack effect genuinely can't be determined.Related
The same logic might apply to
whileanduntilwith statically-known iteration bounds, though those are less common.https://github.com/navicore/patch-seq/pull/272