Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 5658 days ago | link | parent

For a second I thought of calling the old 'loop 'cfor, for the C tradition of writing loops that way, but 'cfor sounds even more explosively exciting. :-p

Anyway, C probably got it from somewhere else as it is. Does anyone know where the start-test-update style originated and whether the technique had some particular name at the time? For all I know, maybe it was developed in Lisp.

EDIT: I've done a little bit of reading. Apparently BCPL just had "for i = 1 to 10 do ..." and several forms of while (repeat, until, etc.), and then B just skipped having a quantifier-style loop convention altogether. B's iterative looping took the form "while ( some_calculation( i++ ) ) { ... }", using side effects like ++ in the loop test. So if C got "for (;;) {}" from anywhere else--if it wasn't just an ad hoc way to put common "while" metaphors on a single line--I've got no clue.

EDIT AGAIN (about an hour later): Looks like LISP 1.5 may have had something like this. Look for "beginning of the loop": http://www.softwarepreservation.org/projects/LISP/book/LISP%...

I can't tell whether that section is from 1962 or from later, since it's the 1985 edition.

Also, I haven't figured out all the details of what LISP 1.5's FOR is supposed to mean, but here's a loose Arc interpretation:

  (mac lisp1_5-for (index init step until . body)
    `(loop (= ,index ,init) (no ,until) ,step
       ,@body))
Finally, I guess I've gone off on a tangent, 'cause I have no idea what this suggests for a name. I guess I still like cfor. ^_^