When you define a function, the following events occur:
The function definition is evaluated, creating a function value.
The function <name> is used to declare a new variable with that name.
The function value is returned as the result of the function definition expression.
Because the function itself is a value stored in a variable, you not only can call the function through the function name variable. By simply referring the function's variable you can also assign the function value to another variable, store it in an array, or pass it as an argument to another function.
The scope of a function variable is the current MAXScript scope context. The variables used inside a function have a local scope, unless the variable was already defined at a higher scope or is declared as global in the function. An exception to this is the function parameter variables, which always have a local scope.
When writing scripts, it is good programming practice to explicitly declare your local and global variables. Implicit declaration is provided as a short-hand, typically used when working in the Listener interactively or developing short scripts. When developing extended scripts, explicitly declaring variables can reduce errors and improve readability of the code. It is also recommend that you declare as local all variables unless you really want them to be global variables. The reasons for this are described in Scope of Variables.
If a function variable is assigned to another variable, a reference to the function value is stored in that variable. Thus while a function variable may no longer be in scope, the function itself still is if the variable it is assigned to has a scope that extends outside the current MAXScript scope context.