Proposed new syntax

Marko Rauhamaa marko at pacujo.net
Thu Aug 17 10:42:58 EDT 2017


Gregory Ewing <greg.ewing at canterbury.ac.nz>:
> I don't agree that the word "for" necessarily implies proceduralness.

Programming languages stole the word from math, where it is
nonprocedural.

Really, "for" is just a preposition. In Algol, for example,
proceduralness was not in the word "for" but in "do":

    for p := 1 step 1 until n do
        for q := 1 step 1 until m do
            if abs(a[p, q]) > y then
                begin y := abs(a[p, q]);
                    i := p; k := q
                end

    <URL: https://en.wikipedia.org/wiki/ALGOL#ALGOL_60>

Pascal is similar:

    for i:= 1 to 10 do writeln(i);

    <URL: https://www.tutorialspoint.com/pascal/pascal_for_do_loop.htm>

As is sh:

    for i in *.py; do
        mv "$i" "$i.bak"
    done

Common lisp uses "do" as well:

    (setq a-vector (vector 1 nil 3 nil))
    (do ((i 0 (+ i 1))     ;Sets every null element of a-vector to zero.
         (n (array-dimension a-vector 0)))
        ((= i n))
      (when (null (aref a-vector i))
        (setf (aref a-vector i) 0))) =>  NIL

    <URL: http://www.lispworks.com/documentation/lw60/CLHS/Body/m_do_do.
    htm>

I guess we have C to blame for the redefinition of the word "for" in
programmers' minds.


Marko



More information about the Python-list mailing list