Proposed new syntax
Rustom Mody
rustompmody at gmail.com
Thu Aug 17 10:48:30 EDT 2017
On Thursday, August 17, 2017 at 8:13:24 PM UTC+5:30, Marko Rauhamaa wrote:
> Gregory Ewing :
> > 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.
And C’s for is just a while with a ‘finally’ clause for its inner block
More information about the Python-list
mailing list