[Edu-sig] Equality and Assignment Notation

Dennis E. Hamilton dennis.hamilton@acm.org
Sun, 7 Apr 2002 12:47:22 -0700


There is no logic to it.

When we started coding programming languages, "=" was in the character set
and it was used for assignment.  It started with Fortran and earlier efforts
at programming languages.  Since Fortran didn't have relational operators in
the first version, there was no problem.  In later versions, .EQ. was used
for the relational operator, allowing Fortran to remain expressible in the
original 48-character set.

When there were relational operators and they needed to be different, the
conventions of ":=" and "=" (Algol family) and "=" and "==" (the Ratfor
family) arose.  The use of := (and =:) to indicate a composed arrow just
didn't set well with some people.  I've always liked it myself.  There may
be some odd connection with ":" not being available in all character sets at
the time these practices were being worked out.

In some languages where there is no possible confusion of assignment and the
equality relational operator, "=" is used both ways.

It is arbitrary.  Simply arbitrary.  Both operations are needed, and their
symbols usually need to be distinct.  That's the whole deal.  Basically,
"==" is now the prevailing custom for the equality relational operator in
programming languages.

Since mathematics doesn't have an assignment operator, and mathematicians
are willing to use other symbols (e.g., arrows) when needed, we are stuck
with this odd cross-over dissonance.  Math teachers here can tell us whether
"==" is creeping into their discipline, and how students adjust to the
different senses of "=" in school.

-- Dennis

-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On
Behalf Of Josh McKenzie
Sent: Sunday, April 07, 2002 10:04
To: edu-sig@python.org
Subject: [Edu-sig] Equality and Assignment Notation


Hi

Why does Python use the equal sign (=) to mean assignment, and use
two equal signs (==) to mean equality? Equality and assignment are
not the same, yet the meaning of the equal sign is universally
understood, so why redefine its meaning?

I know other languages like Java and C++ employ this convention too,
but how does one explain the logic behind this approach?

I'll readily admit to a bias: when I see the notation ':=' in
languages like Pascal, Smalltalk or Eiffel etc, I can at least
understand the distinction these languages attempt to impart to the
user that equality and assignment are similar, but distinct concepts.

It may seem a trivial point to bring up, but while I can explain the
difference between equality and assignment, I cannot explain the
logic of using the '=' and '==' notation.

Thanks :-)

Regards - Josh M.

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx



_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig