Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -6351,7 +6351,9 @@ t/op/filetest_stack_ok.t See if file tests leave their argument on the stack
t/op/filetest_t.t See if -t file test works
t/op/flip.t See if range operator works
t/op/for.t See if for loops work
t/op/for-control-scope.t See if scope of for-control control variable(s) works
t/op/for-many.t See if n-at-a-time for loops work
t/op/for-over-scope.t See if scope of for-over cursor variable(s) works
Comment on lines +6354 to +6356

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 the for $var () variant is called "for-over" and/or "for-over cursor".
Did you come up with these names or are they based on something?

Copy link
Author

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 list

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-list might be clearer then for-over.
Or even for-over-list would be better then for-over.

Copy link
Author

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 list variant as well but it is not always over list. More likely it is for-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-control
  • for-traditional
  • for-with-condition
  • for-threepart

for-over:

  • for-with-cursor
  • for-iterate
  • for-iterator
  • for-values
  • for-in

I wanted to avoid names like:

  • for-each - there are keywords foreach and each which may derail though process
  • for-list - word list represents special structure in language, which differs from array and hash

t/op/fork.t See if fork works
t/op/fresh_perl_utf8.t UTF8 tests for pads and gvs
t/op/getpid.t See if $$ and getppid work with threads
Expand Down
Loading
Loading