Re: First language with conditional assignment?

glen herrmannsfeldt <gah@ugcs.caltech.edu>
Tue, 8 Mar 2011 21:10:19 +0000 (UTC)

          From comp.compilers

Related articles
[11 earlier articles]
Re: First language with conditional assignment? compilers@is-not-my.name (2011-03-07)
Re: First language with conditional assignment? neitzel@gaertner.de (2011-03-07)
Re: First language with conditional assignment? bc@freeuk.com (Bartc) (2011-03-07)
Re: First language with conditional assignment? alex.colvin@valley.net (mac) (2011-03-07)
Re: First language with conditional assignment? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-03-07)
Re: First language with conditional assignment? robin51@dodo.com.au (robin) (2011-03-08)
Re: First language with conditional assignment? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-03-08)
| List of all articles for this month |

From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: Tue, 8 Mar 2011 21:10:19 +0000 (UTC)
Organization: A noiseless patient Spider
References: 11-03-006 11-03-014 11-03-016
Keywords: history, syntax

Stefan Monnier <monnier@iro.umontreal.ca> wrote:


>> if e > f then a := b else a := c;


> It's very sad that programmers are trained to artificially separate the
> world into "statements" and "expressions" and hence end up, as above,
> preferring the less precise and more redundant form.


> a := if e > f then b else c;


Also, when reading it, one has to verify that the same variable
is used in both cases. Now, if you instead (and I usually don't) write:


      if e > f then
            a := b
      else
            a := c;


Then it is at least a little easier to see that they are both a.


In addition, Java compilers tend to verify that a variable is
assigned to before it is used. It might be that this case is
now recognized, but there are many that the compiler isn't sure
about. (It is not just a warning in Java.)


-- glen


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.