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

outer unpacking assignment #57528

Open
jariji opened this issue Feb 25, 2025 · 0 comments
Open

outer unpacking assignment #57528

jariji opened this issue Feb 25, 2025 · 0 comments
Labels
feature Indicates new feature / enhancement requests parser Language parsing and surface syntax

Comments

@jariji
Copy link
Contributor

jariji commented Feb 25, 2025

If the loop executes 0 times, then i should be 0; otherwise it should be greater than 0.

function count_and_maximum(xs)
    i = 0
    m = 0
    for (i, x) = enumerate(xs)
        m = max(m, x)
    end
    (i, m)
end
count_and_maximum(1:5) # (0, 5) is returned, not the desired result.

I want to expose i outside the loop but outer doesn't work with unpacking assignment.

           for outer (i, x) in enumerate(xs)
ERROR: syntax: no outer local variable declaration exists for "for outer"
    for (outer i, x) = enumerate(xs)
#              └──┘ ── Expected `)`

It would be nice to have some way to do this.

@nsajko nsajko added parser Language parsing and surface syntax feature Indicates new feature / enhancement requests labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

2 participants