Talk:Loops/For with a specified step

From Rosetta Code

The Ada solution might also consider using simple loop and then applying a (simple) function to generate the “loop variable”. For example, to loop from 0 to 10 by 2, you might loop from 0 to 5 by 1 and then set another var to the loop var times 2 at each step. (This technique is much more common when trying to loop by floating-point quantities, where feeding them directly into a C-like loop is inadvisable in many languages due to the need to manage imprecision in a way that doesn't blow up in your face...) —Donal Fellows 23:38, 12 July 2009 (UTC)

"useless" examples?

The recent purge struck me as rather aggressive. What constitutes a "useless" example? Knowing that the for statement does not support a step of 2 could itself be useful. I feel those examples should be reinstated. --Pete Lomax (talk) 11:40, 3 February 2021 (UTC)

I understand that’s what omit from is for: That a certain task is just simply impossible in a certain language.
I have narrowed down the task, because I think it is generally known counting loops (for-loops) can be written as semantically equivalent conditional loops (while-loops). I don’t need nobody to show me that, it’s “useless” for me and probably many many other users. I consulted this wiki page to see various flavors of how languages provide means to alter step widths (step, range with width specifier, etc.), not to see various flavors of while loops, you know what I mean?
I strongly oppose reinstating dozens of languages inserting a statement to this page, like: “This isn’t possible, but a while-loop can achieve the same: <code example>”. Well, duh!? It’s just noise. Please leave that out and use omit from.
Root (talk) 11:55, 3 February 2021 (UTC)
Since you're here: 1) what was so offensive about the Axe for loop, or rather where on earth is your first new point coming from at all? 2) Why delete Delphi completely and just the code from Dragon? 3) What suddenly changed to make that [Delphi] ten year old example completely unacceptable? There is a reason why this site has draft tasks, and you should be very cautious (and probably discuss things first) before altering a task that was reviewed and promoted to full task status a decade ago. --Pete Lomax (talk) 12:33, 3 February 2021 (UTC)
One of this site's unwritten rules (or at least I thought it was) is that you don't alter the descriptions of tasks which already have solutions without prior discussion and then set about removing implementations that don't fit.
Moreover, languages which don't support the feature in question are generally allowed some latitude to show how they would do it instead. This is much more informative than just omitting the language from the task altogether.
Without this rule, you could probably justify deleting half the examples on the site as not satisfying the task description in some form or another.
Frankly, I was amazed that the admins let the changes stand! --PureFox (talk) 13:12, 3 February 2021 (UTC)
Perhaps the question is not "What constitutes a "useless" example?" but "who decides ?"
being unusually opinionated and incurious about procedure seems unlikely to be an adequate qualification :-)
Prior discussion always produces a higher quality of decision, and wastes less time, than the instant gratification of isolated impulse Hout (talk) 13:21, 3 February 2021 (UTC)
I reckon for-loops are those listed under Loops/For. This task requires a for-loop to be used. If the code example used here uses a language construct that is not shown at Loops/For, I understand it is not a for-loop.
I’ve deleted the Delphi example, because it’s just a semantically equivalent while-loop. You will find the used language construct demonstrated at Loops/While, but not in Loops/For, hence it’s not a for-loop. This requirement, use for loops, already existed before I edited the page.
I have to make one concession though: Deleting the Axe for loop was impetuous. It’s not normal a control variable can be altered inside a for-loop body. In Pascal, for instance, it is illegal to tamper with the counting variable of a for-loop. I probably just read the first sentence “Axe does not support a step size other than 1” and then threw it out.
I haven’t deleted anything from Dragon. I assume you meant E. The E section still contains code for a custom enumerator (stepRange). The semantically equivalent while-loop, though, is unnecessary.
My intentions were to qualify the task requirements, not alter them. It’s difficult to phrase: I wanted to still permit examples like C, where it is just idiomatic, “normal” to write a conditional expression i < 10 and statement i += 2, because for-loops with a step size of 1 look just the same.
Root (talk) 13:37, 3 February 2021 (UTC)
There is a problem with this: even if a language does not have a for/by statement, there may be an idiomatic equivalent that is not a while loop. The most common is probably an iterator/enumerator/generator or whatever you call that, e.g. in Python. Except that the tasks explicitly forbids the case where the enumeration is not suitable to very large ranges, which I suppose means we don't want a solution where we loop other a range that in the background builds a full list of values in memory. Except it's how you do it in R. You also want to delete the R solution? Then we are losing knowledge: how to achieve that task, as idiomatically as possible, even if it's not perfect? Bastet (talk) 16:37, 3 February 2021 (UTC)
Deletion very rarely adds value.
You may find a contribution 'useless' for your purposes, but we really don't need to know that, and it's not up to you to make that decision on behalf of others.
If you genuinely think that you may have spotted one of the very rare cases where a deletion could somehow add significant value, and that others have somehow missed what you think you can see, then open that discussion, and see what consensus emerges. At worst, you may learn something.
Don't execute the prisoner first, and then consult the court afterwards. Hout (talk) 18:31, 3 February 2021 (UTC)
PureFox: Giving languages a chance to explain that a task can’t be implemented exactly as required isn’t the problem, but we gotta set some limit: Every Turing complete language can achieve any task. In this case though, it just leads to unnecessary repetition, because transforming for-loops to while-loops isn’t “sorcery”. I just prefer to write in the task’s introduction “no while loops”, so this doesn’t bloat the article, you know.
Bastet: Huh. Yes, I wanted to exclude poorly scalable solutions. However, my wording says “custom enumerator”. As far as I understand the seq function used in R is part of the language, right? It’s not a custom addition, it’s already there, so it’s an idiomatically valid solution.
Hout: This is a Wiki, so “shoot first, ask questions later” is OK since everything is in the history, we can “revive” earlier revisions. Wikipedia advertises this as “Be bold!”
Yeah, well, maybe this is one of those “rare” occasions deleting some content is warranted. Can you actually argue for repeating umpteen times “a for-loop can be rewritten as a while loop <code example>” significantly increases the value? It rather improves usability to omit such information. If you can make a good point though, I suggest to deliberately widen the task’s requirements to “demonstrate any kind of loop with a specified step width”, so this kind of discussion never pops up again. On February 2 I read “Demonstrate a for-loop […]” and I just couldn’t (and still can’t) subsume while loops under the term “for-loop”, in consequence I deleted those implementations.
Root (talk) 07:15, 4 February 2021 (UTC)
It seems you don't understand the point of the site. For each language, show how it's done. For the reader interested in language A, it doesn't matter that something is written for languages B, C... Z. Besides, it's not always a while loop, as I have already explained. Bastet (talk) 08:05, 4 February 2021 (UTC)
Good grief ... "This is a wiki, so ..." "In consequence I ..." "I just couldn't ..." ?
Are you serious ? Forgive me, but this is not Wikipedia, the software used is utterly irrelevant, and to protect yourself from a whirlpool of monologue, and the site from an episode of vandalism, you do need to consult and discuss before you rush blindly and self-righteously into deletions. Hout (talk) 08:51, 4 February 2021 (UTC)
I'm throwing my hat into the ring for reversing these changes. If I'm learning a new language and come to Rosetta Code to see how it does a for loop, it's far more useful to see a demonstration of that language's nearest equivalent than it is to see it's been omitted. Furthermore, there is more nuance to many language's iteration constructs than simply considering them to either be generators or clones of one particular language's while and for loops. --Chunes (talk) 10:02, 4 February 2021 (UTC)
Seconded. More value was removed than added, and prior discussion would have protected not only Rosetta value, but also contributor time. Hout (talk) 10:40, 4 February 2021 (UTC)
+1 from me too. If a language has the feature then it should be shown; (we might argue about if other non-feature implementations may also be shown). If a language misses the feature then showing that languages idiomatic replacement, especially for basic constructs, should be encouraged. "Esoteric" languages, for example, may be specifically esoteric in their methods of implementing common constructs.
Entrys can say msomething like "we don't have that construct but...".
Some tasks specifically state that X should be used. Not showing X may always cause issues so starting with an explanation may be best, but gives no guarantee. --Paddy3118 (talk) 11:31, 4 February 2021 (UTC)
+1 as well. For some languages, the requirement just doesn't make sense. For esoteric languages such as brainf*ck of course, but also for more traditional ones: a for loop in assembly? Nope, it's a jump. I can imagine that a few other simplistic languages have goto but no loop. And of course, a range/seq/iterator is yet another approach. Often several are possible (Ruby comes to mind). Rosetta Code can't rigid. Bastet (talk) 14:06, 4 February 2021 (UTC)
Done. This thread has already wasted more time than the "not liked by Root" did collectively over the last decade. --Pete Lomax (talk) 17:07, 4 February 2021 (UTC)