2

I would like to explain the following code to my colleagues:

for options in [{Option.NO_CUTOFFS}, {}, {Option.HEURISTIC}]:
    ...

The following sentence is kind of awkward:

This loop loops on the variants of the algorithm.

What verb can I use instead of "loops" so as to not repeat the subject of the sentence?

0

2 Answers 2

10

This is close to "list of things" or "opinion-based", but I'll risk it anyway, as clear communication about code is part of our profession in my opinion(sic).

  • This loop operates on ...
  • This loop iterates over ...
  • This loop enumerates ...
  • This code loops on ...
  • This statement loops on ...

Pick your choice, or be creative :-)

1

You could frankly convey as much meaning as the existing sentence by just saying "this is a loop".

If you want to be a little clearer about what it does, you could say "this block repeats for each option".

But unless your colleagues are novices in the syntax, then they could work that out for themselves in a flash just by reading the code, without wasting their time listening to an English translation of the obvious.

If you're actually trying to explain something, then perhaps explain where those options come from, what options exist and why, and what consequences each option has, and how this fits into the broader conceptual basis of the code.

Not the answer you're looking for? Browse other questions tagged or ask your own question.