Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v3:subroutines [2024/07/30 22:39] – [Overloading] neils | v3:subroutines [2024/07/30 22:43] (current) – [Overloading] neils | ||
---|---|---|---|
Line 111: | Line 111: | ||
Subroutine overloading, | Subroutine overloading, | ||
- | Overloaded subroutines have the same name but differ in the type, number, or both type and number of parameters. The appropriate subroutine to call is determined at compile-time based on the arguments provided in the call. | + | Overloaded subroutines have the same name but differ in the type, number, or both type and number of parameters. |
+ | |||
+ | ==== Compile-Time Polymorphism ==== | ||
+ | |||
+ | The appropriate subroutine to call is determined at compile-time based on the arguments provided in the call. | ||
Consider the following example: | Consider the following example: | ||
- | | + | |
- | PRINT msg | + | PRINT msg |
- | END SUB | + | END SUB |
- | + | ||
- | SUB PrintMessage(msg AS STRING, num AS INTEGER) OVERLOAD | + | SUB PrintMessage(msg AS STRING |
- | PRINT msg; " "; num | + | PRINT msg; " "; num |
- | END SUB | + | END SUB |
- | + | ||
- | CALL PrintMessage(" | + | CALL PrintMessage(" |
- | CALL PrintMessage(" | + | CALL PrintMessage(" |
<adm warning> | <adm warning> |