Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Use positional scalar disambiguation for Array.splice dispatch #5545

Closed
wants to merge 3 commits into from

Conversation

ab5tract
Copy link
Collaborator

@ab5tract ab5tract commented Mar 31, 2024

This is a followup to #5543 that utilizes the new disambiguation to resolve #5500.

Essentially this allows Array.splice to DWIM for the following syntax:

# applies to all candidate combos for Array.splice, just using '*, *,' as an example   
my @array = <a b c>;
@array.splice(*, *, $[<q e d>]); dd @array
# Mu @array = ["a", "b", "c", ["q", "e", "d"]]
### or 
@array.splice(*, *, $(<e r g o>)); dd @array
# Mu @array = ["a", "b", "c", ("e", "r", "g", "o")]

This syntax is, in my opinion, much more discoverable (and pleasant) than the other means of dealing with "single argument collapse" ([[<h m m>],].

(Note: This PR includes a commit to enable the disambiguation for $())

We infer the intent of the user in this case to be "insert
this array as a single element".

Thus we pass it to the actual array candidate as a new
array containing a single element that as been "listed"
via the common resolution to the single-arg rule
(ie, `[$single,]`).
@ab5tract ab5tract changed the title Use positional scalar disambiguation for Array.splice dispatch Draft: Use positional scalar disambiguation for Array.splice dispatch Apr 1, 2024
@ab5tract ab5tract closed this Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array.splice insists on flattening the replacement
2 participants