Called_as_function()

Test if a procedure was called as a function, ie x = command(y)

CALLED_AS_FUNCTION   Test whether a procedure should alter its parameters

example:

	# Procedure which checks how it is called
	PROCEDURE double
	PARAMETERS w=workspace
	RESULT wres
		IF Called_as_function()		# leave the parameter untouched
			wres = w
			wres.y = w.y * 2.0
		ELSE				# change the parameter
			w.y = w.y * 2.0
		ENDIF
	ENDPROCEDURE

Called_as_function

This procedure is very important for a language which allows procedures to be called either as functions returning results or as keyword commands where the paramters are affected. For example, with the Rebin() command, it may be called either as

	w = rebin( s(1), ... )

where the last thing we would want to do is replace the value "s(1)" with the result of the rebinning. Alternatively we could type

	Rebin w ...

where of course, we would expect to change the contents of workspace "w".

If this check is not made a sequence of functions could produce unexpected results, for example

	>> x = bad_rebin(w, v.x)
	>> y = bad_rebin(w, v.x)
	>> printn (x=y)
	$FALSE

Parameters:

RESULT = (Boolean)

Returns $TRUE if the currently executing procedure was called as a function.