When creating an assignment statement which symbol is used for the assignment operator?

One of the most important features for the construction of programs is the assignment. It was first introduced by Zuse, as the double arrow, ⟹, which he called the Ergibt-zeichen (results or yields sign). The ⟹ symbol represents “implies” in math symbology, meaning that A⟹B, means “if A is true, then B is true“. The systematic use of an assignment constituted a distinct break between computer-science thinking and mathematical thinking [6]. When Zuse introduced the new symbol, he remarked that Z3 + 1 ⟹ Z3 was analogous to the more traditional Z3.i + 1 ⟹ Z3.i+1 [7]. The interesting thing about this symbol is the fact that it directs the flow of information. For example in Plankalkül:

Z + 1 ⟹ Z

This obviously implied that the result of 1 added to the value of Z would be stored in Z. In the original manuscript [8], the symbol is shown as

When creating an assignment statement which symbol is used for the assignment operator?
, however Zuse never actually used the symbol. At the time it was considered one of the more important features in the construction of programs. Rutishauser used the symbol,
When creating an assignment statement which symbol is used for the assignment operator?
in Superplan. In the preliminary work on the language which was to become Algol 58 this evolved into => with the requirement that formula were written in an “appropriate way” [4]. The concept here was to write to the left of the “ergibt” symbol “=>” (ergibt roughly translates to results or yields) the arithmetic expression to be evaluated and to the right the designation of the new quantity defined by the calculation [5]. This ergibt symbol was considered a better choice fore the dynamic flow of the program than the equality symbol.

((a×b)+c) => s
s + 2 => s

For example above, “old” s plus 2 yields “new” s. Interestingly, in the earliest form of the new language, the symbol := was used in the for loop [5]. For example:

for i := 1...n

By the time the design of Algol 58 was finalized, := was chosen, and it has been suggested that this only occurred because the American group pressured the Europeans, who would have preferred to use Zuse’s symbol. Why := was chosen is uncertain. It is possible that it was to represent a left facing arrow, although why <− was not chosen is uncertain. Even the use of <= would have been more meaningful (at the time ≤ was used to represent less-than, as opposed to <=).

By the time of the discussions on the design of ALGOL 60 at the Zurich ACM-GAMM Conference (1958), there is no doubt that there were preconceived notions on the part of the American contingent due to their “experience with FORTRAN” [1]. This is amply shown in the discussion on the operation of assignment. The natural flow of computation is a notation of the form b+7⟶z. However the American’s preferred the reverse [1]. Algol 60 also used the := operator. Algol 60 lended its assignment operator to Algol 68, which was also adopted by Pascal (and its descendants), and Ada.

The use of = as the assignment operator harkens back to Fortran [2]. Here it was touted that a Fortran arithmetic formula closely resembles a conventional arithmetic formula, “it consists of the variable to be computed, followed by an = sign, followed by an arithmetic expression” [2]. The problem is that an expression such as “x=x+1” would be mathematically interpreted as “0=1”. Fortran used the = operator for both initialization, and reassignment.

initialization:   x = 1 
reassignment:     x = x + 1

This was really a poor notational decision, as the = operator is more classically associated with equality. Fortran initially avoided this confusion somewhat because the logical if statement did not appear until Fortran IV in 1965, and even then it used .EQ. as the equality operator. PL/I would use the = for both assignment and equality. But neither Fortran nor PL/I were the direct source of the use of = as a contemporary assignment operator in languages such as C.

In 1963 work began by Christopher Strachey, at the University of Cambridge, on a language which would innovate from Algol 60 – CPL (originally short for Cambridge Programming Language, but later Combined Programming Language). This was a case of a theoretical language never fully implement, but a language doesn’t have to be implemented to have influence. CPL introduced the concept of initialized definition [3], which existed in three forms. The most interesting one is “initialization by value”, implying that when a variable is defined, it may be assigned an initial value obtained by evaluating an expression. For example:

integer x = 37

CPL also included initialization “by reference” (≃), and by substitution (≡). Add to this the use of := for reassignment. The problem now was that = was used for both initialization and equality. At the time CPL was never really implemented, partially because of its size and complexity. The complexity was removed, eventually resulting in BCPL (Basic CPL), designed by Martin Richards in 1967. Among its simplifications, the “three forms of initialization” had to go. The initializations were reduced to a simple =, with := for reassignment, and = for equality. Ken Thompson wanted to convert BCPL to run on the PDP-7. The problem here was that although the BCPL compiler was small, it was still larger than the minimum working memory available on the PDP-7. The solution? Create an even more minimalistic language, B. This resulted in the merging of initialization and reassignment into one operator, =. This made assignment and equality somewhat ambiguous, so Thompson added a new equality operator, == . Thompson was suppose to have noted that “Since assignment is about twice as frequent as equality testing in typical programs, it’s appropriate that the operator be half as long.“. B of course evolved into C. B also introduced a cornucopia of assignment statements some of which would find their way into C. This included 16 assignment operators: =, =|, =&, ===, =!=, =<, =<=, =>, =>=, =<<, =>>, =+, =−, =%, =*, and =/ .

Along other assignment operator roads not taken are symbols derived from languages such as APL. Ken Iverson introduced APL ion 1966, and used  for all assignments. As keyboards changed and lesser known symbols disappeared, even Iverson changed it to =: in his language J. APL influenced S, which in turn influenced R, which uses <− as the assignment operator.

LanguageAssignmentEquality
Fortran = .eq. (FortranIV)
== (Fortran 90)
Algol 60, Algol68 := =
APL =
Pascal (+ descendants), Ada := =
C (+ descendants) = ==
  1. Naur, P., “The European side of the last phase of development of Algol 60”, History of Programming Languages, pp.92–139 (1978)
  2. Backus, J.W., et al. The Fortran Automatic Coding System for the IBM 704 EDPM, IBM (1956)
  3. Barron, D.W., et al. “The main features of CPL”, The Computer Journal, 6(2), pp.134-143 (1963)
  4. Rutishauser, H., “Automatische Rechenplanfertigung bei programmgesteuerten Rechenmaschinen” (1952)
  5. Bauer, F.L., Bottenbruch, H., Rutishauser, H., Samelson, K., “Proposal for a Universal Language for the description of computing processes In: J. W. Carr (ed.), Computer Programming and Artificial Intelligence, University of Michigan Summer School 1958, pp.355-373 (1958)
  6. Knuth, D.E., Pardo, L.T., “The early development of programming languages.” Technical Report, Stanford University (1976)
  7. Zuse, K., “Der Plankalkül”, Manuscript prepared in 1945, published in “Berichte der Gesellschaft für Mathematik und Datenverarbeitung , No. 63 (Bonn, 1972), part 3, 285 pp. English translation in No. 106 (Bonn, 1976), pp.42-244.
  8. Zuse, K., “Über den allgemeinen Plankalkül als Mittel zur Formulierung schematisch kombinativer Aufgaben”, Archiv der Math. 1 (1948/49), pp.441-449.

In Ada you will notice a couple of differences in the way things are coded (as compared to C).

data types (and types, and subtypes)

Ada has integers (I mean does any language not have integers?) They use the classic operators +, –, * and / for arithmetic, and ** for exponentiation. In addition there is rem for remainder and mod for modulus. Here is a typical integer declaration:

x : integer;

Dig a little deeper, and Ada makes it quite easy for the user to define their own types. For example:

type eightbit is range 0..255;

Unfortunately Ada consider this to be a new type, unrelated to any other type (even if it is an integer). So you can’t add a variable with is of type eightbit to an integer. You can also create subtypes. For example:

subtype positive is integer range 1..integer'last;

This creates a subtype positive which spans all positive integer values. Truth be told you can do a lot of different things with types, and subtypes. You could also create eightbit as a subtype.

subtype eightbit is integer range 0..255;

To perform integer I/O you will need the package ada.Integer_Text_IO.

Then of course there are real types. Here is an example of a float:

g : float;

To perform float I/O you will need the package Ada.Float_Text_IO.

To print out floats in a nice way, the put() function uses a number of optional parameters. The default is to display a real with a 3-digit exponent. So 1234.5678 would be displayed as 1.2345678E+003. The parameter Fore specifies how many characters before the decimal point, and Aft specifies after the decimal point. The parameter Exp specifies the number of digits in the exponent. Here is an example:

 put(1234.5678, Fore=>7, Aft=>2, Exp=>0);

displays the output ”   1234.57″, with 7 spaces before the decimal point, 2 after, and no exponent.

There are of course more than one type of integer and float in Ada:

When creating an assignment statement which symbol is used for the assignment operator?

STANDARD LIBRARIES

A list of all the standard Ada95 libraries can be found here.

Assignment statements

Assignment is performed using the classic operator := . This of course is not that uncommon in languages which evolved before C. So an assignment is of the form:

radius := 20902231.0;

This means that the equals operator, =,  is used for testing equality in expressions. For example in an if statement:

if x = 0 then
   Put_Line("Zero!");
end if;

If you try to use == in an if statement you will get a compiler error of the form:

== should be =

Which stops assignments happening in decision statement logicals.

One of the worst mistakes ever made (in my humble opinion) by the designers of C was that related to the use of = to signify assignment. The choice of = as an assignment operator harks back to Fortran, where it was deemed a good idea to be copied by hoards of language designers since. In early Fortran it *may* have made sense, considering that equality was designated using the term .EQ., although in later years (F95), this too devolved to the ubiquitous == inaugurated in C. The problem lies with the fact that mathematics uses the = operator to denote a comparison for equality. The use of = in Fortran essentially forced the equality operation, A = B, the left operand is made to equal the expression which exists in the right operand. It was Algol which surprisingly led the surge to look for an alternative, using := instead.

None of this would be an issue, if C didn’t allow code like this:

if (something = 0)
    something = something + 1;

But it does. There is nothing seemingly wrong about this except that the value of the variable something will always be set to 0, regardless of what its value was before the if statement. That’s because when it evaluated the expression in the if statement, it sets something to 0, and because the value 0 is false, it skips the inner workings of the if statement. It does not check to see if something is zero.

There of course was a simpler solution. Programming has been around for over 60 years, why not (and I know this is radical) include two new symbols: ← to denote assignment (thereby stopping anybody from writing a+b =c), and ≠ for inequality. Then = could be used for its original intended purpose. Oh, and while we’re at it let’s include ≤ and ≥. Wrapped in the mists of time there is a language called APL which used such syntax.

I mean it’s not rocket science. More functionality can be added to existing keys on the keyboard, and keys like _, and ~ could be moved, replaced by ←, and ≠. As noted by Niklaus Wirth in “Pascal and its Successors”, (Software Pioneers, 2002), “…  if x=y has been used for centuries to denote equality of x and y, we should refrain from the arrogance of replacing it with x==y”.

When creating a program using C++ which symbol is used for the insertion operator?

In C++, stream insertion operator “<<” is used for output and extraction operator “>>” is used for input. We must know the following things before we start overloading these operators. 2) These operators must be overloaded as a global function.

What is := in programming?

:= it means "set equal to" An assignment with syntax. v := expr sets the value of variable «v» to the value obtained from expression «expr». Example: X := B Sets the Definition of X to the value of B.

Which symbol is used for an assignment statement in a flowchart?

In a flowchart the symbol that represents an assignment statement is an oval. Variable names cannot include spaces.

What symbol is used when assigning a value to a variable?

Assignment (=) The simple assignment operator ( = ) is used to assign a value to a variable.