local

Syntax:	local ( VAR1 , VAR2 , VAR3, ... )

Description:

	The local statement forces a function to resolve specified
	variable reference within the function itself. Each local
	variable is initialized UNDEFINED, and is destroyed after
	execution leaves the function. Each time execution enters the
	function, the local variables are re-initialized.

	Declaring argument variables local copies the value of the
	argument variable into the local variable of the same
	name. The argument variable is not accessible while function
	is executing. In essence, this procedure forces arguments to
	be passed by value.

	For example:

	mgs = function(A)
	{
	  local (A)
	  m = A.nr;  n = A.nc;
	  for(k in 1:n)
	    {
	      r[k;k] = norm( A[1:m;k], "2");
	      q[1:m;k] = A[1:m;k]/r[k;k];
	      for(j in k+1:n)
		{
		  r[k;j] = q[1:m;k]' * A[1:m;j];
	          A[1:m;j] = A[1:m;j] - q[1:m;k] * r[k;j];
	        }
	     }
	  return << q = q; r = r >>;
	};


	The function `mgs' uses the local statement to forces
	pass-by-value on its argument `A'. Since A is passed to the
	function by value, modification of A will not affect the
	original variable. `A' is modified within the for-loop without
	affecting the original function argument.

See Also: FUNCTION, global, static
