[449] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next last

Re: assignments change (fix)

daemon@ATHENA.MIT.EDU (Fri Sep 23 20:26:12 1994 )

From: BRANDON@cc.usu.edu
Date: Fri, 23 Sep 1994 17:48:06 -0600 (MDT)

< I treated assignment as a statement because I believe assignment
< expressions lead to horizontally-organized code, which I believe is
< difficult to read.  Given the opportunity, many programmers will tend
< to use a small number of long lines of code over a large number of
< short lines of code; since I felt that Coldmud should enforce uniform
< code with vertical organization, I didn't give programmers that
< opportunity.  In fact, you'll notice that no expressions in Coldmud
< can have side-effects on local variables (and only method calls and
< primitive calls can have side-effects on the database); therefore,
< programmers are forced to make only one change per statement.

This is very true (and is an argument I had forgotten about).

< If you're going to change assignment to :=, I would recommend changing
< equality to a single equal sign, or you will have the false illusion
< of being similar to Pascal for assignment.  Another option is to
< change 

Well, one of the ideas of changing an assignment to ':=' is that every operator
involving an equals sign would be part of a two character sequence (hence the
chance of confusion would be MUCH less).  By making equality be a single '='
character pulls the confusion back into it, and you may as well just stick with
'=' as an assignment.

I don't think the need for assignment expressions is big enough to come up with
a solution for them.  However, this whole discussion has caused me to feel that
changing the assignment operator (even if it doesn't become an expression)
would be a good idea (for the above reason of commonality).  I would also not
mind seeing '+=' '-=' and '++' '--' (the first two I would really appreciate,
I can immediately think of several instances where they would simplify things).
The last two we probably dont want, especially if we have '+='.  Spam code:

Now:        value = 1 + 1;
(with new:  value := 1 + 1;   )

Possible:   value += 1;

Perhaps:    value++;

Sure they all do the same thing, but each is nicer than the other.  The last,
however, is probably pulling ColdC into more complexity.

And to reply back to Colin's comment about people not being able to distinguish
'=' from '==' not being programmers, I have been polling people who's opinions
I consider worth listening to.  The following is from one of these discussions:

XXXX [to Brandon]: considering i just wiped out all the .email_address's at
 XXXX the other day by mistyping '==' as '=', i'd prolly prefer ':='
XXXX thinks the whole 'we should use '=' cuz C does' is just plain stupid

I think said person would be quite offended that you don't consider them a
programmer (not to mention the case with everybody being named 'Guest' at
LambdaMOO because of the same slipup on yduJ's behalf).  Yes, the second case
is in relation to assignment expressions.

Basically, consider (in relation to operators only, do not consider
assignment expressions or another while loop configuration):

                  Old         New

                  '<='        '<='     (Unchanged)
                  '>='        '>='     (Unchanged)
                  '!='        '!='     (Unchanged)
                  '=='        '=='     (Unchanged)
                  '='         ':='
                              '+='     New
                              '-='     New
                              '++'     New *
                              '--'     New *

* I don't consider these two as important as the two above them, although they
  would be nice.

But, enough from me...