Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37373
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2019-09-24 22:39 -0700 |
| References | <59bee1c7-4afe-445e-8f73-b3248e75040c@googlegroups.com> <qmdu75$1vo0$1@gioia.aioe.org> |
| Message-ID | <58927a8f-1d2c-40fe-b198-e7ecb586d141@googlegroups.com> (permalink) |
| Subject | Re: A proposition for a conditional loop. |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
Den tisdag 24 september 2019 kl. 22:27:25 UTC+2 skrev R.Wieser:
> Jonas,
>
> > Why not do....
> >
> > step=1;
> > x="something"
> > do until (this equal that) { inc x, step}
> > then do { whatever }
>
> Because that is not valid javascript ?
>
> > I mean doing this with while just not possible it will be a weird
> > statement.
> >
> > while (this != that[x]){
> > x++;
> > ]
>
> And thats not valid javascript either. Both also create a problem : What
> are the non-js parts (like "{ inc x, step}" or "that[x]) actually supposed
> to mean ? I can /guess/, but I should not be forced to do that ...
>
> In short: When posting examples its a good idea to use a /working/ one. It
> makes it much easier to understand.
>
> Like this:
>
> x=0
> while (x <5) {
> ..
> ..
> // do stuf
> ..
> ..
> x += 2
> }
>
> And yes, that works.
>
> Now ask yourself: What /good/ does it do to smear a "for" loop out over
> three seperate lines, with the incrementing of the loopcounter being as far
> away from its initialisation & checking as possible ?
>
> Compare it with a "for" loop:
>
> for (x=0; x<5; x += 2 {
> ..
> ..
> // do stuf
> ..
> ..
> }
>
> Here everything that matters to the loop is close together - on a single
> line even - , making it much harder to make a "what was the loopcounter
> variable and by how much should it advance again ?" mistakes.
>
> But, bottom line: use the loop you like best, as it doesn't really matter to
> the code itself. (below the surface the "for", "while", "do while" and "do
> until" loops work exactly the same).
>
> Regards,
> Rudy Wieser
I think you missed the point Rudy, did you check the picture i posted?
There is actually two types of loops, there it "do while" and "do until" loops, i just state that the "do until" does not have a satisfactionary semantics either with for or while.
Because you will have to use negations until your condition is satisfied, and **after** loop finished do what you try to achieve.
Thus it ends up.
while (this!=that[x]){
x++;
}
do_It();
This is not a satisfying semantics.
or if you use for
for (x=0;x<that.length;x++) {
if (this==that[x]){
do_It();
break
}
}
A child see that ain't a good way to do it, you break up the statement, and have to use a break to not loop unnecessary.
Now compare to this BASIC approach, with an extra then to encapsulate the codpiece to a single unit.
step=1;
x="something"
do until (this==that[x]) { inc x, step}
then do { doIt(); }
Yeah i know i am a genius, but it does not take a genius to see which approach have the correct semantics, just common sense. Something alot of ENTP lacks.
Well i am well aware about it is not Javascript syntax, i just told you a more correct semantics for the javascript syntax.
I mean your example does not even make sense, it is not do until, your example is do while.
So... I am just here to complain, but my complaints do make sense.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 00:55 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 01:05 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 01:14 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 01:16 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-24 05:12 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-24 22:27 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-24 22:39 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 09:05 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 02:47 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 13:13 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 05:13 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 15:04 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 06:10 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-25 15:50 +0100
Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-25 16:00 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 10:20 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 10:26 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-25 19:18 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 12:19 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-26 10:48 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-26 04:38 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-26 18:05 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-26 10:54 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-27 10:06 +0100
Re: A proposition for a conditional loop. dr.j.r.stockton@gmail.com - 2019-09-27 02:34 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 05:32 -0700
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 05:36 -0700
Re: A proposition for a conditional loop. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-27 20:23 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 12:45 -0700
Re: A proposition for a conditional loop. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-27 22:05 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 14:39 -0700
Re: A proposition for a conditional loop. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-28 00:16 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 17:10 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-28 17:28 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-28 11:34 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-28 22:23 +0200
Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-28 21:42 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-29 07:40 -0700
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-29 18:33 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-29 09:58 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-29 19:18 +0100
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-29 21:02 +0200
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-29 13:54 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-28 10:41 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 13:17 -0700
Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-27 13:41 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 06:01 -0700
Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-27 14:03 +0100
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-27 19:23 +0100
Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 12:06 -0700
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-28 14:43 +0100
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-25 21:47 +0100
Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-26 10:49 +0100
Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 17:07 +0200
csiph-web