Language - Assignment

Card Puncher Data Processing

About

An assignment is an expression that gives a value to a variable.

An assignment is not a statement but an expression.
The assignment is generally contained in one statement but not always, you may have several assignment expression in one statement.

Type and syntax

Implicit

Simple form

In its simplest form, an assignment statement has a variable on the left of the = sign and an expression on the right. This ordered form, and similar variations, is quite prevalent in modern programming languages.

variableName = value
  • Other variations exists but are less prevalent.
value -> variableName
// or
value <- variableName

Generally in a language syntax,

Tuple

A tuple assignment allows several variables to be assigned at once.

Example: x becomes y and vice versa.

x, y = y, x

Operator (Compound)

An assignment operator (also known as Compound operator) is a short cut language structure that combine a math operation with assignment,

Example:

x = x * scale

can be rewritten as

x *= scale

The same is true for all:

Example of compound operator:

  • +=,
  • -=,
  • *=,
  • /=

Explicit

Assignment statements are an explicit form of assignment, but there are many places in a program where an assignment occurs implicitly:

  • a function call implicitly assigns the argument values to the corresponding parameter variables;
  • a return statement implicitly assigns the return operands to the corresponding result variables;
  • and a literal expression for a composite type such as an array

Go Example:

medals := []string{" gold", "silver", "bronze"}

implicitly assigns each element, as if it had been written like this:

medals[0] = "gold" 
medals[1] = "silver" 
medals[2] = "bronze"

Documentation / Reference





Discover More
Event Centric Thinking
(Stream|Pipe|Message Queue|Event Processing)

From an abstract point of view, a stream is a sequence of aninfinite cardinality (size) delivered at unknown time intervals. list Streams: are inputs and outputs of operations may be also buffers...
Cpu Moore Law Transistor
Bit - Bitwise and Shift binary operator

Operator on bit. See Reference/Operators/Bitwise_Operators assignment operator the bitwise arithmetic operators (~, &, ^, and |) and the shift operators (<<, >>, and >>>). The bitwise...
Imperative Vs Functional
Code - Imperative Programming

Imperative vs Functional mariofusco/status/571999216039542784 Imperative vs reactive programming In an imperative programming setting, the expression a:=b+c would mean that a is being assigned the...
Compiler
Compiler - Semantics Analysis

Semantic analysis is the phase in which the compiler: adds semantic information to the parse tree builds the symbol table. This phase performs semantic checks such as: type checking (checking...
Card Puncher Data Processing
Go - Type

in Go the rules are simple: the assignment types must exactly match, and nil may be assigned to any variable of interface or reference type. Type declarations most often appear at package...
Javascript - Assignment

assignment in Js See Reference/Operators/Destructuring_assignment
Card Puncher Data Processing
Language - (Variable | Field)

Variables in a computer language are used to store data information. A variable is a piece of storage containing a value. Variables created by declarations are identified: by a name, such as x, ...
Model Funny
Language - Argument

Argument are variable passed to a function during execution. There are then an automatic explicit assignment between the variable of the caller and the variable of the callee.
Card Puncher Data Processing
Language - Declaration

A declaration names a program entity and specifies some or all of its properties such as: its type and default value := is a declaration, whereas = is an assignment.
Card Puncher Data Processing
Language - Equality

The Equality operators model the Equivalence relation: equality is parallel to (for affine spaces) is in bijection with isomorphy The Equality operators are a subset of the comparison operator....



Share this page:
Follow us:
Task Runner