[net.lang] Using indentation for statement grouping.

guido@boring.UUCP (09/26/85)

In article <205@graffiti.UUCP> peter@graffiti.UUCP (Peter da Silva) writes:
>Then you could indicate compound and continued statements by indentation:
> [long example]
>Any programming languages actually do this, by the way?

Yes.  B, for instance(*).  A small example of a B program to give you the
taste of it:

HOW'TO PI n:	\ Print first n digits of decimal expansion of pi
    WRITE "3 . "
    PUT 3, 0, 40, 4, 24, 0, 1 IN k, a, b, c, d, e, f
    PUT n IN stop
    WHILE 1=1:
        WHILE e = f:
            WRITE e
            PUT stop-1 IN stop
            IF stop <= 0: QUIT
            PUT 10*(a-e*c), 10*(b-f*d) IN a, b
            PUT floor(a/c), floor(b/d) IN e, f
        PUT k**2, 2*k+1, k+1 IN p, q, k
        PUT b, p*a+q*b, d, p*c+q*d, f IN a, b, c, d, e
        PUT floor(b/d) IN f

Try to figure out how it works.  Hint: arithmetic on rational numbers
gives exact results; PUT a IN b means b:=a.  B has no declarations (but
checks the types of the variables used for consistency).

(Now I come to think of it, several recent topics in this group relate
to B in some way: B's assignment goes from left to right, and B has
a scheme of "fuzzy" operator precedences which tries to be maximally
intuitive and forbids combinations like a/b+c that are ambiguous to the
human reader.
B would also make an excellent language for scientific programming
if it weren't for its speed [or lack thereof]: B is an interpreted
language.  You can buy a B interpreter for the IBM-PC and compatibles
these days.)

	Guido van Rossum, CWI, Amsterdam (guido@mcvax)

(*) No relation with the predecessor of C.

Disclaimer: I work on the design and implementation of B and thus am not
unbiased.  On the other hand, we don't earn a cent by selling it (yet).