Cold Help System: Programming: ColdC Reference Manual: Implementation: Methods: Code


Arguments, Local Variables and the ColdC Code for a method are defined all at once, within one block of text formatted as:

arg arg1, arg2, .., @rest;
var var1, var2, ..;

statement1
statement2
..
..

The first line is the Argument Declaration. The second line is the Local Variable Declaration. Any remaining lines are standard ColdC statements, also known generically as ColdC Code.

The arg declaration gives a list of argument variables, whose values will correspond to the arguments passed with the message. The arg declaration may be omitted if the method does not take any arguments. If the final argument variable is preceeded with the splice operator (an at-sign `@`), then the method can accept any number of argments; the variable rest will contain a list of the remaining arguments. If the final argument is not defined in this way, the method can only accept the defined number of arguments, and sending any more will cause a ~numargs error to be thrown.

The var declaration is used to define local variables. Any variable given in the list will exist during the execution of the method. In the case of conflicts with object variables, the local variable is used first. The var declaration may be omitted if no local variables are declared.

Once the method begins normal execution, both arguments and local variables are treated the same (as local variables). The statements statement1, statement2, .. compose the ColdC Code body.

A Method is defined using the ColdC function add_method(), or within a Textdump.


Code | Flags | Access


the Cold Dark