overload (--)
Inputs
- None.
Outputs
- None.
overload creates a pending overload specifier in the current scope.
That pending specifier is consumed by the next successful local creation. Intervening operations do not consume it.
A public overload can be selected directly by module loading. A private overload participates in same-name lookup only after its module has already been loaded through some other public name.
When followed by use, the pending specifier marks every directly imported name as an overload and clears when the import completes, including an empty import.
Behavior
- If another overload specifier is already pending in the same scope, using
overloadagain is invalid. - After the next successful local creation, the pending overload specifier is cleared.
- A pending overload specifier is invalid for
importVariable. - If the scope ends before the pending overload specifier is consumed, the program is invalid.
- Pending
privateorvirtualcoexist with the pending overload specifier.
Example
overloadExample.mpl
private overload virtual hiddenHelper: 3;
overload virtual helper: 1;
virtual publicAgain: 2;
test.mpl
"overloadExample.helper" use
{} 0 {} [
"-- directly selected public overload --" printCompilerMessage
helper printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- directly selected public overload --
1
indirectLookupExample.mpl
"overloadExample.publicAgain" use
{} 0 {} [
"-- following created name is public --" printCompilerMessage
publicAgain printStack _:;
"-- public overload still participates in lookup --" printCompilerMessage
helper printStack _:;
"-- private overload also participates after module load --" printCompilerMessage
hiddenHelper printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- following created name is public --
2
-- public overload still participates in lookup --
1
-- private overload also participates after module load --
3
See also
NAME: ...;node—Pushes a name onto the name stack and creates a local by consuming that name and one data-stack object.defbuiltin(object name --)Creates a named local or field using a known Text name.exportFunctionbuiltin(inputsSchema output options callable name --)Exports a named function built from a Block and a signature; pendingoverloadapplies there.importFunctionbuiltin(inputsSchema output options name --)Declares or imports a named function with the supplied signature; pendingoverloadapplies there.importVariablebuiltin(schema name --)Creates a local that refers to external variable storage; pendingoverloadis invalid there.privatebuiltin(--)Marks the next local created byNAME: ...;ordefas non-public, sousedoes not import that name from the module.virtualbuiltin(--)Marks the next local created byNAME: ...;ordefas static;virtualis the historical name for this declaration modifier.