Inconsistent behavior of "..." in [] constructor with non-list values #1368
Labels
No labels
UX
active development
backlog
blocker
bootstrap
bounty
bug
dependencies
discussion
documentation
duplicate
enhancement
flaky test
help wanted
invalid
javascript
question
release
tendentious
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mighty-gerbils/gerbil#1368
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?
As discovered during the documentation effort in PR #1367 , the
...operator in the[...]list constructor has some counter-intuitive behaviors when the preceding expression is not a list.This issue is to track the work to define and implement a more consistent and user-friendly behavior.
As Vyzo noted in the PR review, there are two main problems:
Discarding Behavior: An expression like
[1 2 3 ... 4]evaluates to(1 2 4), discarding the3. A possible alternative behavior would be to treat the non-list value as a tail, producing(1 2 3 . 4).Unwrapping "Bug": An expression like
[42 ...]evaluates to42instead of(42). This is considered a bug and is inconsistent with the general list-building behavior.The goal is to fix these inconsistencies and then update the documentation to reflect the new, correct behavior.
I think that destructuring a non-list should be an error, not "maybe turn a
the tail into an atom we try to splice an atom as the second last pair ...
we'll turn that atom into a cons and steal the cons from the next one
only if it's the last one, otherwise unspecified"
Why does "splice 3" become "destructure the following cons only if it is
the last the last cons"? I disagree 100% with that idea, it makes no sense.
I also think the *Unwrapping "Bug" *should be an error. Rather than
making things worse we should make them better :).
ie:
What should happen here?
[1 2 3 ... 4 ... 5 ...]
How about here?
[1 ... 2 ]
I think the only way to make it consistent as a list builder is to error
when trying non-consistent non-list behavior. No Monkey patching allowed.
Thoughts? --drewc
On Tue, Sep 30, 2025 at 8:19 AM Henri Fouda @.***>
wrote:
yeah, error is also consistent behavior.
I think
...should basically behave as if you invokeappend, and we have:So I vote for an error.