contents   index   previous   next



FUNCTION REDIRECTION

 

Normally, an object is either a function or it is not. If it is a function, it can be invoked or used as a constructor such as by Func(); or new Func();. Each of these behaviors can be overridden. Two special members can be added to an object to override, _call and _construct. They are used in the two instances above, _call when invoked as a regular function and _construct when used in a constructor with the new operator. These special members must themselves be functions that are called in the appropriate case. It is possible to turn a regular non-function object into a callable function by giving it an _call member and a constructable object likewise by giving it an _construct member.