<div dir="ltr"><div>Here is a summary of my idea about for-loop.<br>It focuses on readability and does not <br>take in account possible technical nuances.<br>This is my first attempt to write a full proposal <br>and I suppose it is ok to post it here. <br>Many things (readability) can raise opinion based dispute, <br>so it is sort of my opinion. <br>I am not sure how topical/realistic is it, <br>or contains technical flaws, so your note and<br>recommendations are welcome.<br><br><br>Proposal<br>--------<br><br>Introduce a more classical, "Fortran-ish" loop syntax.<br>The simplest syntax could be:<br><br>for i somekeyword 10 :<br><br>which logically will be the same as <br><br>for i in range(10) :<br><br>Keyword supposed to have sense only inside the statement, <br>thus not interfere with variables and other keywords. <br>At this moment the proposal will be to use the word "over": <br><br>for i over 10 :<br><br>The choice of the word is based only on its look - middle<br>sized, has related meaning(?), and easy to type. Of course, <br>if a better word can be found, it can be used. <br><br>Note: the meaning of the word is of much less <br>importance than optical qualities. <br><br>Other good looking options:<br><br>for i count 10 :<br>for i range 10 :<br>for i steps 10 :<br>for i sieve 10 :<br><br>Parameters same as in range():<br><br>for i over  a, b, step :   <br><br>is the same as<br><br>for i in range(a, b, step) :<br><br><br>Rationale <br>-----------<br><br>Removing the brackets will help concentrate on other<br>parts of code, though it has some price, since if more <br>than one range parameter is used, it loses some emphasis. <br>This is easiliy compensated by IDE's syntax highlighting,<br>namely by slightly graying out the keyword.<br><br>Currently the loop statement uses the word "in".<br>This word creates rather unpleasant visual 'stick and hole' <br>effect on eyes due to its short size. Is quite noticable, <br>especially in case of one-letter varaibles (e.g. for i in ...).<br>And the 'bulky' range() part is bit too heavy.<br>More problems to 'holes' effect, especially in<br>monospaced editors, adds the form of glyphs "i" and "n" <br>which both have vertical stick structure and also interfere <br>with the very common variable name "i".<br><br>Also new sytax needs less typing.<br><br><br>Examples<br>--------<br><br>Common use case: <br><br>L = [1,3,5,7]<br><br>for i over len(L):<br>   e = L[i]<br><br>or:<br><br>length = len(L)<br>for i over length:<br>   e = L[i]<br><br>Nested:<br><br>for y over  0,480 :   <br>   for x over  0,640 :   <br>      putpixel (x, y)<br><br>or:<br><br>width = 640<br>height = 480<br>for y over  0, height :<br>   for x over  0, width :<br>      putpixel (x, y)<br><br>Surprisingly good result is achieved if simply <br>remove the keyword and put more space:<br><br>for y    0, height :<br>   for x    0, width :<br>      putpixel (x, y)<br><br>But similar effect can be achieved by<br>graying out the word with syntax highlighting.<br><br>Compare with existing syntax:<br><br>for y in range(0,480) :   <br>   for x in range(0,640) :   <br>      putpixel (x, y)<br><br>for y in range(0, height) :   <br>   for x in range(0, width) :   <br>      putpixel (x, y)<br><br><br>Notes<br>-------<br><br>Although it is true that the whole idea is more <br>about cosmetics, still the  for-loop is important<br>structural component and slight improvement<br>could count.<br></div><div><br><br></div>Mikhail<br></div>