TScript

Overloading

Homepage
TScript
Overloading
 

Overloaded Function Declarations

To support optional parameters and the thing called "overloading of functions" the following syntax has been introduced:

message (string), (string, string), (string, string, integer) : integer;

// Valid calls
message ('Hallo');
message ('Hallo', 'System Message');
message ('Hallo', 'System Message', 45);

// Bad calls for function message
message ('Hallo', 45, 'System Message');

You can declare more than one argument pattern but only one return value type!

OnExEval Event

To tell the user which kind of argument pattern was choosen a new kind of OnEval event was introduced. OnExEval event has a additional parameter "argpat" indicating which pattern was choosen.

message ('Hallo'); // argpat = 0
message ('Hallo', 'System Message', 1); // argpat = 2

The decision which pattern fits the arguments is made dynamically during the evaluation.

If you define two equivalent argument patterns the first from left to right is selected.