Parameter Passing: Difference between revisions

Content added Content deleted
No edit summary
Line 143: Line 143:


===Example [[M2000 Interpreter]]===
===Example [[M2000 Interpreter]]===
All parameters are passed by value is a stack of values. This stack is a collection of values, and that collection is passed from a module to a module as is, at also return back. Functions start with a fresh stack of values, and at that stack all the parameters from the call stored there. To read parameters from start of values we use Read. A definition Function a(k as integer) {code here} is identical with that: Function a {read j as integer : code here}. Because we can use read at any point of a module or function we can handle parameters with many ways before actually pop them from the stack, like we can check type, we can rearrange and use the stack of values for any use.
All parameters are passed by value is a stack of values. This stack is a collection of values, and that collection is passed from a module to a module as is, and also used for return back values. Functions start with a fresh stack of values, and at that stack all the parameters from the call stored there. To read parameters from start of values we use Read. A definition Function a(k as integer) {code here} is identical with that: Function a {read j as integer : code here}. Because we can use read at any point of a module or function we can handle parameters with many ways before actually pop them from the stack, like we can check type, we can rearrange and use the stack of values for any use.


We can pass by reference values, although actually we store a weak reference and at the Read statement this reference change to normal if it is valid (or an error occur). So call thisModule &Z pass a string as a weak reference, and at the thisModule we have the Read &t which make t to hold the same memory as the Z.
We can pass by reference values, although actually we store a weak reference and at the Read statement this reference change to normal if it is valid (or an error occur). So call thisModule &Z pass a string as a weak reference, and at the thisModule we have the Read &t which make t to hold the same memory as the Z.
Line 168: Line 168:
call kappa
call kappa
</syntaxhighlight>
</syntaxhighlight>





===Example [[Z80 Assembly]]===
===Example [[Z80 Assembly]]===