Recent Post

Parameter Passing

Call by value : "Actuals copied to formal".but not formals to actuals.
Call by reference : "Actuals and formals uses same address space".
Call by value result (Restore) : "Actuals coiped to formals and formals copied to Actuals".
Call by Result : "Actuals not copied to formals" , but formals copied to actuals.
Call by Constant : Formal values are never changed.
Call by Name : The textual substitution of every occurrence of a formal parameter in the called routines body by the corresponding actual parameter.
Call by Text : Same as call by name,but if variables are named same as local variables then it prefers local.
Call by Need : Memory allocates only if formals are used in function.



Pass-by-Name  (call by name)

- If the actual parameter is a scalar variables, then pass by name is equivalent to pass by reference.
- If the actual parameter is a constant expression then pass by name is equivalent to pass by value.
- If the actual parameter is an array element then pass by name may be different from any other method ,because the value of the subscript expression can change during execution between the time of various reference.
- If the actual parameter is an expression that contain a variable,pass by name is again different from any other method, because the expression is evaluated for each access to the formal parameter at the time the variable is reached.

No comments