Skip to content

Nomenclature question: what is the EXPR in for PATTERN in EXPR { } called? #1841

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

Open
jieyouxu opened this issue Jun 4, 2025 · 0 comments
Open

Comments

@jieyouxu
Copy link
Member

jieyouxu commented Jun 4, 2025

Location

https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops

Context

I was reviewing a test cleanup PR rust-lang/rust#141974, and I was trying to say something about the EXPR in

for PATTERN in EXPR {
    //         ^--- what is this expr called?
    // ...
}

but I couldn't find a good term for this12. The current grammar calls this EXPR

Expressionexcept struct expression

whereas for e.g. match EXPR { .. } or if let PATTERN = EXPR { .. }, there's a more "meaningful name" for that EXPR, which is the scrutinee expr.

Footnotes

  1. In the community discord, terms like "interatee" or "iterable" or "into-iterable" were suggested, but yeah.

  2. Nadrieril came up with "loopee", which is an excellent term 😆

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

No branches or pull requests

1 participant