[comp.lang.misc] History of :=

karl@haddock.ISC.COM (Karl Heuer) (01/20/88)

In article <214@oink.UUCP> jep@oink.UUCP (James E. Prior) writes:
>I find := for assignment to be quite obnoxious.  ... misleading ...
>In math : is often used for comparison, as in ratios.
>
>Cyber folklore around the office has it that := originated in Europe
>as something that looked similar to [left arrow].

If they wanted to preserve the appearance, I would expect that "<-" or "<="
would have been a better choice.  I've always believed that the ":=" (in ALGOL
and its successors) was taken directly from the identical mathematical symbol.
Since you find it "misleading", I presume you've never seen the mathematical
usage of ":="?

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
(Followups to comp.lang.misc; this is not C-related anymore.)

hirchert@uxe.cso.uiuc.edu (01/22/88)

>>I find := for assignment to be quite obnoxious.  ... misleading ...
>>In math : is often used for comparison, as in ratios.
>>
>>Cyber folklore around the office has it that := originated in Europe
>>as something that looked similar to [left arrow].
>If they wanted to preserve the appearance, I would expect that "<-" or "<="
>would have been a better choice.  I've always believed that the ":=" (in ALGOL
>and its successors) was taken directly from the identical mathematical symbol.
>Since you find it "misleading", I presume you've never seen the mathematical
>usage of ":="?

I was a math major in college and I can't ever remember seeing := used in a
mathematical rather than computer science context.  In what branch of math
is it used and what does it mean?  If there is a current mathematical usage
of this symbol, are you sure that it didn't derive from the computer usage?
(After all, Algol and its descendants have been around for a long time.)

>Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
>(Followups to comp.lang.misc; this is not C-related anymore.)

Kurt W. Hirchert
National Center for Supercomputing Applications

cosell@cosell.bbn.com (Bernie Cosell) (01/24/88)

Well, the first time _I_ saw := was in Algol.  It is all real hazy now,
but as I recall, Algol had _three_ variants of '=':
   =    boolean -- tested if a equalled b 
   :=   assignment -- evaluated b and assigned that value to a.
   ::=  definition -- a was defined to be 'b' as a macro.

(in C parlance, they would be, roughly, = -> ==; := => =;
::= -> #define)
   __
  /  )                              Bernie Cosell
 /--<  _  __  __   o _              BBN Labs, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com

karl@haddock.ISC.COM (Karl Heuer) (01/25/88)

In article <51300003@uxe.cso.uiuc.edu> hirchert@uxe.cso.uiuc.edu writes:
>I was a math major in college and I can't ever remember seeing := used in a
>mathematical rather than computer science context.

I don't see it used very often, but it means "is defined to be equal to".  The
opposite symbol "=:", which means that the RHS is the term being defined, is
sometimes used when it's more convenient (as in A = B = C =: D, which might
mean that A can be reduced to B and thence to C, and that we will henceforth
refer to this expression by D).

>If there is a current mathematical usage of this symbol, are you sure that it
>didn't derive from the computer usage?

No, I'm not certain.  I'm guessing, based on the differing semantics, that
it's more likely to have migrated the other way.  And where I've seen it used
this way in Mathematics, there was no computer context.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

ok@quintus.UUCP (Richard A. O'Keefe) (01/25/88)

In article <20123@bbn.COM>, cosell@cosell.bbn.com (Bernie Cosell) writes:
> Well, the first time _I_ saw := was in Algol.  It is all real hazy now,
> but as I recall, Algol had _three_ variants of '=':
>    =    boolean -- tested if a equalled b 
>    :=   assignment -- evaluated b and assigned that value to a.
>    ::=  definition -- a was defined to be 'b' as a macro.
Algol 60 hasn't got macros.  Algol 60.1 hasn't got macros.  Algol 68
hasn't got macros.  Burroughs Extended Algol has macros, but you do
	define foo(a,x) = replacement;
It isn't hard to find out about Algol 60.  Why not check the facts
before spouting?

:= has been used in mathematics for a long time to mean "is defined as".
For example:
	interior(S):= complement(closure(complement(S)))
Another convention is = with "def" subscripted, e.g.
	o       __
	S =    (S')'
	   def
----

cef@H.GP.CS.CMU.EDU (Charles Fineman) (01/26/88)

I can not believe that someone has not quelled this discussion yet! 
Perhaps the people who know better are to busy guffoughing (sp?) over
it. The terminology "a := b" means that a is "defined to be" b. For 
example, let a be defined to b the mapping from a number to the of numbers
that are relatively prime to that number can be writting as (subistituting
the proper notation where appropriate):

	a(x) := {y <in> Z+ | lcm(x,y)=1}

In general, the use of ":=" in programming languages is associated with
(if you will) first order objects like numbers and such. In mathematics,
":=" is used in *all* levels of abstraction (read n-order objects). 

The only reason that ":=" was used instead of "=" is because of an 
ambiguity in ALGOL (the same ambiguity exists in C BTW). Since it is
legal to have an assigment as a term in an expression, there had to
be a way to distinguish between equality and assignment. This is the
same reason why C uses "==" for equality.


Anyways, I have a *real* hard time believing that anyone with a formal
CS education (even more so for someone with a *MATH* education) has never
seen this notation before. It's been at the height of fasion for the least 
the past 200 years. I got my B.S. degree in math of at CMU and was unundated
with ":=" daily. Anybody out there who got a formal education in CS or Math
and did not learn this, should make sure that their almamada realizes that
they are not teaching the students all they should be. I realize that this
may be a little drastic for one little bit of notation, but notation is
alphabet of mathematics. How can you expect the graduates of such a school
to be useful in a world where they never learned the language.


This is my first flame in months, it just that something like this
bothers me (I was brought up to be a stickler for consistent notation).
Its like a grammer teacher teaching your kid street-talk. 

	Charles Fineman
	Carnegie-Mellon University
	cef@h.cs.cmu.edu (via seismo)

keithc@cs.qmc.ac.uk (Keith Clarke) (01/27/88)

Expires:

Sender:

Followup-To:

Distribution:

Keywords:


In article <3921@aw.sei.cmu.edu> firth@bd.sei.cmu.edu.UUCP (Robert Firth) writes:
>Algol-60 does not allow an assignment within an expression, and there
>would be no ambiguity using '=' for both assignment and equality.  This
>is because the designers of Algol-60 had the good sense to make it a
>statement language.  They then used for equality the only reasonable
>symbol, and for assigment they used the left-pointing arrow, to capture
>the notion that something flowed from the RHS to the LHS.

Algol 60 doesn't allow assignments within expressions, but
there would too be an ambiguity, because it allows multiple
assignment:

(1) p :=  q = r
compare q and r, put the answer in p.

(2) p := q := r
put the value of r into q and also into p.

Parsers normally don't use type information to sort out
syntactic ambiguities, so it doesn't really matter if = isn't the
operator for comparing booleans; it is certainly the operator
for something!
I suspect the designers of Algol 60 would have used different
symbols anyway, since they stand for quite different things.
Maybe the statement/expression distinction faded because of a
wish to generalise constructs like the multiple assignment
statement?
-- 
Keith Clarke

UUCP:      keithc@qmc-cs.uucp   or    ...seismo!mcvax!ukc!qmc-cs!keithc
Internet:  keithc@cs.qmc.ac.uk           Post:  Dept of Computer Science
JANET:     keithc@uk.ac.qmc.cs                  Queen Mary College
Easylink:  19019285                             University of London
Telex:     893750 QMCUOL G                      Mile End Road
Fax:       +44 1 981 7517                       London E1 4NS
Voice:     +44 1 980 4811  x3908                England

wolpert@hpisla.HP.COM (David Wolpert) (01/28/88)

>>legal to have an assigment as a term in an expression, there had to
>>be a way to distinguish between equality and assignment. This is the

>Algol-60 does not allow an assignment within an expression, and there
>would be no ambiguity using '=' for both assignment and equality.  This
>is because the designers of Algol-60 had the good sense to make it a
>statement language.  They then used for equality the only reasonable

Algol DOES allow assignment as a term in an expression.  At least,
Burroughs XALGOL did, and I can't imagine Algol without it.  Proof
by quoting excerpt from manual:

<expression> ::=
        <arithmetic_expression> | <Boolean_expression> |
        <designational_expression> | <concatenate_expression>

<arithmetic_expression> ::=
        <simple_arithmetic_expression> | <if_clause>
        <arithmetic_expression> ELSE <arithmetic_expression>

<simple_arithmetic_expression ::=
        <term> | <adding_operator> <term> |
        <simple_arithmetic_expression> <adding_operator> <term>

<term> ::=
        <factor> | <term> <multiplying_operator> <factor>

<factor> ::=
        <primary> | <factor>*<primary>

<primary> ::=
        <unsigned_number> | <variable> | <function_designator> |
        ( <arithmetic_expression> ) | <partial_word_designator> |
        <string> | <concatenate_expression> | <assignment_statement>
                                              -----here--it--is-----

I'm (almost) positive that this was a standard feature of Algol,
and not a Burroughs extention.  Wish I had a copy of the "plain"
language definition to quote from.

Actually, there were only two things I missed when I changed from
Algol to Pascal: assignment inside expressions, and OWN variables
(and, maybe a little, being able to hop into GTL/pseudo-Lisp).
                       _  _
                      / \/ \      David Wolpert   (303) 667-5000 x3533
  /_  __   HEWLETT    \    /             Measurement Systems Operation
 / / /_/   PACKARD     \  /          P O Box 301 - Loveland, CO  80539
    /                   \/                wolpert%hpisla@hplabs.HP.COM
======================================================================
"Be joyful always; pray continually; give thanks in all circumstances"

ps: I describe Algol as a "block" language; Pascal is closer to being
a "statement" language, since it doesn't allow the programmer to nest
blocks freely.

jejones@mcrware.UUCP (James Jones) (01/28/88)

In article <715@PT.CS.CMU.EDU>, cef@H.GP.CS.CMU.EDU (Charles Fineman) writes:
> I can not believe that someone has not quelled this discussion yet! 
> Perhaps the people who know better are to busy guffoughing (sp?) over
> it. The terminology "a := b" means that a is "defined to be" b. For 
> example, let a be defined to b the mapping from a number to the of numbers
> that are relatively prime to that number can be writting as (subistituting
> the proper notation where appropriate):
> 
> 	a(x) := {y <in> Z+ | lcm(x,y)=1}

I'm not sure whether it reflects on my, uh, alma mater, but I must admit
to never having seen ":=" used this way.  I've seen Russell & Whitehead's

	x = y Df

They used dots rather than parentheses for grouping in *PM*, in the
fashion, I think, of Peano.  Could that be where this whole mess came up?

There was also x =df y for infix purists. :=)  However, what I would almost
always see is either the straight equals sign

"Let a(x) = etc."

or the Bourbakioid

"define a : Z+ -> P(Z+) [there's no script font on most terminals, so I
can't use script capital P for "the power set of..."] by

	a : x |-> {y <in> Z+ | gcd(x, y) = 1}"

(where some texts, particularly number theoretical ones, would just say
(x, y) for gcd (not lcm; I'm sure the original poster meant gcd)).  Maybe
I didn't hang out with the right crowd. :=)  Let's all just have a good
guffaw, recognize that human factors (other than wear and tear on typing
fingers) had nothing to do with the choice of syntax for C (I scrupulously
avoid the word "design" in this context), and hope that language designers
will do better next time.

	James Jones

firth@sei.cmu.edu (Robert Firth) (01/29/88)

In article <3921@aw.sei.cmu.edu> firth@bd.sei.cmu.edu.UUCP I wrote:

  Algol-60 does not allow an assignment within an expression, and there
  would be no ambiguity using '=' for both assignment and equality.  This
  is because the designers of Algol-60 had the good sense to make it a
  statement language.  They then used for equality the only reasonable
  symbol, and for assigment they used the left-pointing arrow, to capture
  the notion that something flowed from the RHS to the LHS.

In article <367@sequent.cs.qmc.ac.uk> keithc@qmc.ac.uk (Keith Clarke) writes:

  Algol 60 doesn't allow assignments within expressions, but
  there would too be an ambiguity, because it allows multiple
  assignment:

  (1) p :=  q = r
  compare q and r, put the answer in p.

  (2) p := q := r
  put the value of r into q and also into p.

  Parsers normally don't use type information to sort out
  syntactic ambiguities, so it doesn't really matter if = isn't the
  operator for comparing booleans; it is certainly the operator
  for something!

Thank you, Keith, I should have mentioned this point.  A modern parser
would indeed perceive a syntactic ambiguity here.  Back in 1959, such
things were not worried about overmuch (there are other syntactic
ambiguities in the original Report), provided there was some way to
resolve the problem.

The semantic resolution, of course, is that EQUALS returns a Boolean
result but cannot take Boolean operands, so we have

	p,q,r all  Boolean: p ASSIGN q ASSIGN r
	p,q,r none Boolean: ditto
	p Boolean, q,r not: p ASSIGN q EQUALS r

Other combinations are illegal.

My post should have made it more clear that "ambiguity" was intended to
mean something stronger that "context-free syntactic ambiguity".  Sorry.
And, of course, there would be a true ambiguity if EQUALS took Boolean
operands, as many Algol compilers permit.

firth@sei.cmu.edu (Robert Firth) (01/30/88)

In article <5410001@hpisla.HP.COM> wolpert@hpisla.HP.COM (David Wolpert) writes:

>Algol DOES allow assignment as a term in an expression.  At least,
>Burroughs XALGOL did, and I can't imagine Algol without it...

Suggest you refer to the 'Report on the Algorithmic Language Algol-60',
and imagine a little harder.

[Yes, the above is possibly offensive, but I am VERY TIRED of people
 who won't even bother to look up absolutely standard references]

peter@sugar.UUCP (Peter da Silva) (02/10/88)

In article <3921@aw.sei.cmu.edu>, firth@sei.cmu.edu (Robert Firth) writes:
> This
> is because the designers of Algol-60 had the good sense to make it a
> statement language.

a) Why does this show good sense?

b) If I'm not mixing my Algol and PL/1 here, doesn't Algol allow:

	a := if b then c else d;

?
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.

rlee@sun-oil.ads.com (Richard Lee) (02/11/88)

In article <1448@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes:
=In article <3921@aw.sei.cmu.edu>, firth@sei.cmu.edu (Robert Firth) writes:
=> This
=> is because the designers of Algol-60 had the good sense to make it a
=> statement language.
=
=a) Why does this show good sense?
=
=b) If I'm not mixing my Algol and PL/1 here, doesn't Algol allow:
=
=	a := if b then c else d;
=
=?


According to the _Revised Report on the Algorithmic Language ALGOL 60_
(CACM Jan 63), Algol 60 does allow statements of that form.  It is still
considered a "statement language".

One has to be careful when discussing "Algol", since there is an Algol
60 and an Algol 68, and they have dramatic differences.