overload

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.

Behavior

Example

overloadExample.mpl

private overload virtual hiddenHelper: 3;
overload virtual helper: 1;
virtual publicAgain: 2;

test.mpl is the primary runnable example file. indirectLookupExample.mpl records the separate lookup case after module loading through another public name.

test.mpl

"overloadExample.helper" use

{} 0 {} [
  "-- directly selected public overload --" printCompilerMessage
  helper printStack _:;
  0
] "main" exportFunction

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

Module-loading wrapper lines are omitted below.

Expected Output During Compilation

-- directly selected public overload --
1
-- following created name is public --
2
-- public overload still participates in lookup --
1
-- private overload also participates after module load --
3

See also