Procedure Overloading

To overload a procedure is to make two or more procedures with the same name but different parameter lists. You can make many related procedures, but it is not necessary to select different names. To do this, you change the parameter list.

Instructions

When you overload a procedure, you must obey the instructions that follow.

Same name
Each overloaded set of procedures must use the same procedure name.
Different signatures
The differences between each procedure in a set of overloaded procedures must be at least one from this list:
  • Number of parameters
  • Sequence of the parameters
  • Data types of the parameters
  • Number of type parameters (for a generic procedure)
The procedure name and the above items together are known as the signature of the procedure. When you call an overloaded procedure, the compiler uses the signature to make sure that the call agrees with the implementation.
Items not part of the signature
You cannot overload a procedure unless the signatures are different. The items that follow are not part of the signature:
  • Procedure types and modifiers, for example, Function, Method, and @Shared
  • Names of parameters or type parameters
  • Constraints on type parameters (for a generic procedure)
  • Parameter modifiers, for example, ByRef and Optional
  • If it returns a value or not
  • The data type of the return value
Although you cannot use the above items to overload procedures, you can use them with correctly overloaded procedures. Thus, the compiler ignores those items not applicable to the signature.

How overloading helps

TODO

See also