Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31195
| From | Lewis Perin <perin@panix.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: JSlint finds for loops intolerable |
| Date | 2016-08-28 16:50 -0400 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <pc74m64lis5.fsf@panix1.panix.com> (permalink) |
| References | <npug18$166s$1@gioia.aioe.org> <for-20160828204739@ram.dialup.fu-berlin.de> |
ram@zedat.fu-berlin.de (Stefan Ram) writes:
>emf <emfril@gmail.com> writes:
>>for (var i = 0; i < 10; i += 1) {
>> ...
>>}
>>var i = 0;
>>while (i < 10) {
>> ...
>> i += 1;
>>}
>
> When one compares this, one can see:
>
> - The for loop is a Statement.
>
> - The corresponding sequence that uses
> »while« is a StatementList with /two/
> StatementListItems.
>
> So the corresponding statement would be
>
>{ var i = 0; while( i < 10 ){ ... ++i; }}
>
> . But »...« could be quite long, so it might
> be hard to see »++i« at the same time as the
> start of the loop.
>
> The for loop-head is one »chunk« in the brain.
> The control of the while loop is distributed
> in two, or possibly three, different places,
> it cannot be seen as a single idiom by the brain.
>
> While theoretically the while loop /is/ simpler,
> it might be too low-level. It seems that the for
> loop comes more naturally to humans. Especially
> for counting loops and similar loops.
>
> Due to hoisting »for( var« might be misleeding,
> so I deem »for( let« more natural.
>
I’m generally sympathetic to the idea that one criterion for judging
programs is how easy they are to reason about. But there’s often a
glibness about this when it isn’t clear who is doing the reasoning: a
person or a computer program?
/Lew
---
Lew Perin / perin@acm.org
http://babelcarp.org
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JSlint finds for loops intolerable emf <emfril@gmail.com> - 2016-08-28 06:56 -0400
Re: JSlint finds for loops intolerable "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-08-28 14:28 +0200
Re: JSlint finds for loops intolerable emf <emfril@gmail.com> - 2016-08-29 22:35 -0400
Re: JSlint finds for loops intolerable Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-30 12:11 +0200
Re: JSlint finds for loops intolerable "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-09-03 20:54 +0200
Re: JSlint finds for loops intolerable Scott Sauyet <scott@sauyet.com> - 2016-09-03 23:03 +0000
Re: JSlint finds for loops intolerable Scott Sauyet <scott@sauyet.com> - 2016-09-03 22:47 +0000
Re: JSlint finds for loops intolerable Lewis Perin <perin@panix.com> - 2016-08-28 16:50 -0400
Re: JSlint finds for loops intolerable Lewis Perin <perin@panix.com> - 2016-08-28 18:49 -0400
Re: JSlint finds for loops intolerable Lewis Perin <perin@panix.com> - 2016-08-28 19:13 -0400
Re: JSlint finds for loops intolerable $Bill <news@todbe.com> - 2016-08-28 14:59 -0700
csiph-web