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

Name placeholder (like _ in Go) #73

Closed
vtereshkov opened this issue May 2, 2021 · 4 comments
Closed

Name placeholder (like _ in Go) #73

vtereshkov opened this issue May 2, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@vtereshkov
Copy link
Owner

Would it be possible to add something like _? It can be very useful.

Originally posted by @marekmaskarinec in #70 (comment)

@vtereshkov
Copy link
Owner Author

@marekmaskarinec It would not be easy, but I'll consider implementing it.

@vtereshkov vtereshkov added the enhancement New feature or request label May 2, 2021
@skejeton
Copy link
Contributor

If this is limited to declarations, as it usually is then I think I know what to do.

@vtereshkov
Copy link
Owner Author

@skejeton Not only declarations. Also assignments, the for...in loop, etc., etc.

Before we start, we need to answer several questions. For example,

  1. Do we really need it after Allow variable redeclaration from multiple return function call #329 is done? @marekmaskarinec ?
  2. The Go spec has 34 mentions of "blank", i. e., the _. All of them (except those related to generics) may or may not be applicable to Umka.
  3. How should it be implemented internally? As an identifier or as a new token kind? If the former, what type should it have? And in how many places should it be treated specially?
  4. How to properly skip the right-hand side expressions in a, _, _, b, _, c, d = e, f, g, h, i, j, k? They can have different sizes. And none of them should remain on the stack as garbage.

@marekmaskarinec
Copy link
Contributor

I don't think this issue is worth implementing, since we now have #329. It may be useful in for loops, but it's actually not required thanks to variable shadowing. This works just fine:

fn main() {
        a := []int{ 1, 2, 3 }
        for _,i in a {
                for _,j in a {
                        printf("%d * %d = %d\n", i, j, i * j)
                }
        }
}

@vtereshkov vtereshkov closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants