Page 1 of 1
Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 1:19 am
by Tenaja
I'd like to request a Repeat {command list} while (condition) statement. I know it's very similar to Repeat Until, but sometimes it's easier or more readable to repeat WHILE a condition is true rather than UNTIL it's
not true.
Especially if the condition has quite a few tests that span several lines...
Thanks!
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 2:02 am
by Blood
This request makes no sense whatsoever. You already have all the types of loop you need.
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 2:23 am
by netmaestro
The While..Wend block does exactly what you ask, it just doesn't use the Repeat keyword before While. It's already implemented.
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 7:53 am
by DarkDragon
netmaestro wrote:The While..Wend block does exactly what you ask, it just doesn't use the Repeat keyword before While. It's already implemented.
No, thats a head controlled loop and no foot controlled like "Repeat : Until". He just wants to have a "do : while" loop like "Repeat : Until" but without inverting the Until block. But he could also just use Macros and build it himself:
Code: Select all
Macro WhileEx(condition)
Until Not (condition)
EndMacro
Define i.i
i = 0
Repeat
i + 1
WhileEx(i < 10)
Debug i
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 8:45 am
by blueznl
Can't you do something like...
Code: Select all
While Not ( ... load of crap ... )
...
Wend
I guess I'm not properly understanding the question

Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 8:59 am
by DarkDragon
blueznl wrote:Can't you do something like...
Code: Select all
While Not ( ... load of crap ... )
...
Wend
I guess I'm not properly understanding the question

This is a head controlled loop. Learn the basics of programming please!!

See my code for what he wants. The foot controlled loop will ALWAYS pass at least once.
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 9:09 am
by blueznl
So...
Code: Select all
Repeat
...
Until Not ( ... load of crap ...)
?
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 9:12 am
by Tenaja
Thankfully, the ignorant have already been addressed. (Thanks.) For the opinionated... yes, we already have all the loops we "need," but if Fred quit at all we "need," then there would only be If/Goto statements!
On the other hand, this forum is called the "Feature Requests and Wishlists" forum. I, personally, prefer to look for conditions without inverting them. Hence, the "wish."
Here is a comparison of eating newlines on a text file...
Repeat
getnextchar
until (!newline or EOF)
vs.
Repeat
getnextchar
while (newline and !EOF)
Clearly, they do the same thing, and the logic gives the same result. However, depending upon the intent of the code, repeating
while you are eating newlines may be "easier" to read than eating until you have no newlines.
It's back to the "glass half full or half empty" argument. (For me, it depends on which direction I'm going!)
No, I don't expect Fred et al to jump every time I ask for something, but at least I ask for things that are simple to implement, and he's free to ignore my request anyway.
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 11:40 am
by DarkDragon
blueznl wrote:So...
Code: Select all
Repeat
...
Until Not ( ... load of crap ...)
?
Yes, exactly thats what he wants. But its not useful and more complicating the syntax. Other languages also only have one statement for foot controlled loops.
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 4:00 pm
by Blood
Tenaja wrote:Thankfully, the ignorant have already been addressed. (Thanks.) For the opinionated... yes, we already have all the loops we "need," but if Fred quit at all we "need," then there would only be If/Goto statements!
Why should Fred waste his time implementing a whole new loop just because you won't use the Not operator?
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 9:08 pm
by blueznl
Well, it's a WISH list, so we can all post things we'd like to see in our favorite language. The good thing about a forum is that we (users) can spar a bit about the usability of the feature, and they (the devs) can see what's interesting to the community, and how the community would react to certain ideas.
I thought I was overlooking something, but now I understand
By the way, I strongly believe loops with the conditional parameter WHEN ENTERING are often a better way to program, as they keep code more readable. Again, it's a matter of choice, but isn't that the case with anything? (Including girlfriends

)
Re: Do or Repeat While() on wish list...
Posted: Wed Dec 01, 2010 9:45 pm
by Tenaja
blueznl wrote:
By the way, I strongly believe loops with the conditional parameter WHEN ENTERING are often a better way to program, as they keep code more readable. Again, it's a matter of choice, but isn't that the case with anything? (Including girlfriends

)
While I agree, in principle, there are two problems... either the loop isn't guaranteed to run a minimum of once (as in repeat...until or do...while) OR the compilers parsing of it is a huge pain because you'd have to buffer the conditional test and paste it at the end of the loop code. And since most compilers don't buffer code, that would be a huge rework of the system.
Re: Do or Repeat While() on wish list...
Posted: Thu Dec 02, 2010 2:16 am
by Blood
blueznl wrote:By the way, I strongly believe loops with the conditional parameter WHEN ENTERING are often a better way to program, as they keep code more readable. Again, it's a matter of choice, but isn't that the case with anything? (Including girlfriends

)
Matter of choice is not an option, both forms are needed to solve certain problems. For example a bubble sort algorithm can be more elegantly solved using a do...while loop.
The loops as they are, are fine.