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!linus!philabs!cmcl2!seismo!mcvax!boring!jack From: jack@boring.UUCP Newsgroups: net.lang Subject: Reading programs left-to-right. Message-ID: <6571@boring.UUCP> Date: Sat, 10-Aug-85 17:18:16 EDT Article-I.D.: boring.6571 Posted: Sat Aug 10 17:18:16 1985 Date-Received: Mon, 12-Aug-85 22:35:40 EDT Reply-To: jack@mcvax.UUCP (Jack Jansen) Organization: AMOEBA project, CWI, Amsterdam Lines: 43 Apparently-To: rnews@mcvax.LOCAL Something that caught my attention a while ago is the following: Why do most programming languages do assignments like This has two major disadvantages over in my opinion. 1. The second case is simpler to produce good code for. In the first case, the compiler should remember the expression, which may involve putting it on the stack or something like that if the is very complicated. 2. (More important) The second case is much easier to read. Everyone (well, almost everyone) reads and writes a program left-to-right: if(a+b == 3) Calculate a+b, then compare to 3, as opposed to if(3 == a+b) Remember 3 for later, calculate a+b, compare to what we remembered previously. I tend to read a statement like foo[i+j].bar->bletch = a+b in the order 2 3 4 5 1 (although it could be discussed that 2 and 3 should be the other way around). So, wouldn't a+b => foo[i+j].bar->bletch be more logical? Moreover, I what about the infamous C construction a[i++] = i I remember seeing a language with the second type assigments once, but it hasn't seemed to catch on. Does anyone know any good reasons for this? -- Jack Jansen, jack@mcvax.UUCP The shell is my oyster.