Difference between revisions of "Assignment"

From Mesham
Jump to navigationJump to search
(Created page with '==Syntax== In order to assign a value to a variable then the programmer will need to use variable assignment. [lvalue]:=[rvalue]; Where ''lvalue'' is a variable and ''rvalue''…')
 
m (5 revisions imported)
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
[lvalue]:=[rvalue];
 
[lvalue]:=[rvalue];
  
Where ''lvalue'' is a variable and ''rvalue'' a variable or expression
+
Where ''lvalue'' is a memory reference and ''rvalue'' a memory reference or expression
  
 
== Semantics==
 
== Semantics==
  
Will assign a value to a variable
+
Will assign a ''lvalue'' to ''rvalue''.
  
 
== Examples==
 
== Examples==
  
var i:=4;<br>
+
function void main() {
var j:=i;
+
    var i:=4;
 +
    var j:=i;
 +
};
 +
 
 +
In this example the variable ''i'' will be declared and set to value 4, and the variable ''j'' also declared and set to the value of ''i'' (4.) Via type inference the types of both variables will be that of ''Int''
 +
 
 +
''Since: Version 0.41b''
  
 
[[Category:sequential]]
 
[[Category:sequential]]

Latest revision as of 15:44, 15 April 2019

Syntax

In order to assign a value to a variable then the programmer will need to use variable assignment.

[lvalue]:=[rvalue];

Where lvalue is a memory reference and rvalue a memory reference or expression

Semantics

Will assign a lvalue to rvalue.

Examples

function void main() {
   var i:=4;
   var j:=i;
};

In this example the variable i will be declared and set to value 4, and the variable j also declared and set to the value of i (4.) Via type inference the types of both variables will be that of Int

Since: Version 0.41b