Difference between revisions of "Stack"
From Mesham
Jump to navigationJump to searchm |
|||
Line 18: | Line 18: | ||
[[Category:Type Library]] | [[Category:Type Library]] | ||
− | [[Category: | + | [[Category:Compound Types]] |
[[Category:Allocation Types]] | [[Category:Allocation Types]] |
Revision as of 17:55, 12 January 2013
Syntax
stack[]
Semantics
Instructs the environment to bind the associated variable to stack frame memory which exists for a specific function only whilst it is alive. Once the corresponding function has returned then the memory is freed and hence this variable ceases to exist.
Note: This type, used for function parameters or return type instructs pass by value
Example
var i:Int :: allocated[stack];
In this example variable i is declared as an integer and allocated to all processes (by default) and also on the stack frame of the current function. Note how we have omitted the optional braces to the stack type as there are no arguments.
Default allocation strategies
Type | Default allocation strategy |
---|---|
All element types | Stack |
Array | Heap |
Record | Stack |
Reference record | Heap |