Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site boring.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!mcvax!boring!guido From: guido@boring.UUCP Newsgroups: net.lang Subject: Using indentation for statement grouping. (Re: Operator Precedence) Message-ID: <6630@boring.UUCP> Date: Wed, 25-Sep-85 20:55:30 EDT Article-I.D.: boring.6630 Posted: Wed Sep 25 20:55:30 1985 Date-Received: Sat, 28-Sep-85 07:43:10 EDT References: <262@pedsgd.UUCP> <1502@umcp-cs.UUCP> <205@graffiti.UUCP> Reply-To: guido@mcvax.UUCP (Guido van Rossum) Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 43 Apparently-To: rnews@mcvax.LOCAL 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). Brought to you by Super Global Mega Corp .com