-
Notifications
You must be signed in to change notification settings - Fork 601
perly - simplify non-terminal bare_statement_for #23873
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
happy-barney
wants to merge
7
commits into
Perl:blead
Choose a base branch
from
happy-barney:hpb/cleanup
base: blead
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,958
−1,710
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8abd20f
[tests] New assert function `assume` with test message first
aa66a03
[tests] New tests focused on scope behaviour of loop variables
1715b53
[parser] Formalize KW_FOR as a keyword starting new lexical scope
c877835
[parser] Split `for` statement into two variants
ce8db55
[parser] Add `clause_mexpr` to remove duplicated code
e65090d
[parser] Rename `for-over` variable(s) to `cursor` (position pointer)
69dbd25
[parser] Extract for-over cursor declarations into `clause_for_cursor`
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit [tests] New tests focused on scope behaviour of loop variables
The
for (;;)variant is now called "for-control" and thefor $var ()variant is called "for-over" and/or "for-over cursor".Did you come up with these names or are they based on something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are based on loop behaviour:
for-control- for loop with control variable (C-like syntax)for-over- loop over listThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preamble: when I'm looking at code/when reviewing I tend to be picky about names because I want names to be expressive and instantly make it clear what it is.
Let me clarify the question: did you come up with these names or are they already well established somewhere?
The reason why I'm asking: before this PR I would have no clue what a "for control" loop would mean (I - obviously - know the construct but I've never seen it being referred to as a "for control" loop. perlsyn for example refers to it as c-style loop but that also is not a great name). Same with "for over": I would not immediately link it with
for (@list)If the names are already established somewhere then it's my knowledge that is lacking and then the names are good.
If you came up with the names then it might be worthwhile to think about/discuss alternative/better names so that it is immediately clear to everyone what it means/what it is used for.
Just an initial thought
for-listmight be clearer thenfor-over.Or even
for-over-listwould be better thenfor-over.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, now I understand your question.
No, these exact names were not used in code base so far.
I though about
listvariant as well but it is not always over list. More likely it isfor-over-iterable-with-cursor(in future can be object "implementing interface iterable" or result of function containing "yield")I also though about introducing new directory (eg:
grammar/expression-for-control-scope.t) where tests will be named after respective grammar rule they are testing (in this case with suffix what is tested).Regarding discussion: IMHO PR review is proper place. Rest kind of discussions tends to stale.
Few other ideas (used also LLM to suggest some as well):
for-control:for-with-controlfor-traditionalfor-with-conditionfor-threepartfor-over:for-with-cursorfor-iteratefor-iteratorfor-valuesfor-inI wanted to avoid names like:
for-each- there are keywordsforeachandeachwhich may derail though processfor-list- wordlistrepresents special structure in language, which differs fromarrayandhash