Function

Functions are one of the most important features of a programming language. Our concept of function is any value that can be called using syntax . Most values such as scalars, matrices, strings, regular expressions, lists, hash tables, sets, and classes can act as functions. More useful functions are created by writing a subprogram. When such a function is called, a work space of local variables is created, and input argument values are passed to the work space, and the code of the function is executed. When the execution of the code of the function is done, the local variables of the function are cleared, but the output argument value is kept and passed back to the caller.

Shang functions are powerful and very easy to use. They also have a number of new features which are not supported in most other programming languages. For example, function can have parameters which make them customizable; their arguments can have domains, so that the interpreter can automatically check if arguments are valid; functions can be added, subtracted, multiplied, and chained to make up new `pseudo' functions; functions can be part of a matrix; a partial list of input arguments can be passed a function to create a new function whose arguments are the ones missing from the list; etc.



Subsections
oz 2009-12-22