Skip to main content, values)

Calls the function with a non-default context object


Device + Agent


Name Type Description
newContextObject Object An alternative context object
values Any One or more function parameter values




When any Squirrel function is called, it is passed a hidden first parameter, this, which contains a reference to the object which ‘owns’ the function: the Global Table in the case of functions defined in the main body of a Squirrel program, or the instance of a class in the case of class methods.

If the called function uses a variable not declared local to that function, Squirrel will check whether the variable is a member of the passed this object before reporting an error.

Use the function call() to specify an alternative object that will be passed into the function’s this parameter in place of the default value when the function is called. This provide the function with direct access to class members of the passed object.

In addition to the context object, call() must be passed sufficient parameters to match those required by the function itself, ie. those parameters without default values specified in the function definition. In this respect, call() essentially exposes the first parameter passed to all functions but which is usually hidden:, 42, "fish");

For a version of this call which sidesteps Squirrel’s error callback, see pcall().