Difference between revisions of "Static"

From Mesham
Jump to navigationJump to search
m (5 revisions imported)
 
(3 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
== Example ==
 
== Example ==
  
var i:Int :: allocated[static];
+
function void main() {
 +
    var i:Int :: allocated[static];
 +
};
  
 
In this example variable ''i'' is declared as an integer and allocated to all processes (by default) and also on static memory. Note how we have omitted the optional braces to the ''stack'' type as there are no arguments.
 
In this example variable ''i'' is declared as an integer and allocated to all processes (by default) and also on static memory. Note how we have omitted the optional braces to the ''stack'' type as there are no arguments.
 +
 +
''Since: Version 1.0''
  
 
== Default allocation strategies ==
 
== Default allocation strategies ==
Line 18: Line 22:
  
 
[[Category:Type Library]]
 
[[Category:Type Library]]
[[Category:Composite Types]]
+
[[Category:Compound Types]]
 
[[Category:Allocation Types]]
 
[[Category:Allocation Types]]

Latest revision as of 15:44, 15 April 2019

Syntax

static[]

Semantics

Instructs the environment to bind the associated variable to static memory. Because it is allocated into static memory, this is the same physical memory per function call and loop iteration (environment binding only occurs once.)

Note: This type, used for function parameters or return type instructs pass by value

Example

function void main() {
   var i:Int :: allocated[static];
};

In this example variable i is declared as an integer and allocated to all processes (by default) and also on static memory. Note how we have omitted the optional braces to the stack type as there are no arguments.

Since: Version 1.0

Default allocation strategies

Type Default allocation strategy
All element types Stack
Array Heap
Record Stack
Reference record Heap