- 2.2.15 -
Table of Contents
2. TMT Pascal Language Description
2.2. Pascal Language Structure
2.2.15. Overloaded Functions
Targets: MS-DOS, OS/2, Win32
TMT Pascal supports function overloading.
The concept of overloading relates to the idea
that you can define procedures and functions with the same name.
TMT Pascal does not look only at the referenced name, however,
to resolve a procedure or function call.
The count and data types of formal parameters are also considered.
Syntax:
overload fun_name = qualified procedure identifier;
Where the fun_name is a re-defined name for some standard function.
When a re-defined function is used, TMT Pascal uses the last definition
that could be applied toward operands of given types.
For example, this fragment:
function FooA(x:dword):dword;
begin
fooA:=x*2;
end;
function FooB(x,y:dword):dword;
begin
fooB:=x+y;
end;
overload foo=FooA;
overload foo=FooB;
begin
writeln(foo(10));
writeln(foo(20,10));
end.
will cause FooA function to be used when one argument specified,
and FooB function will be used when two arguments specified.
See also:
User Defined Operators
- 2.2.15 -