overload (--)

Inputs

Outputs

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

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