private (--)
Inputs
- None.
Outputs
- None.
private creates a pending visibility specifier in the current scope.
That pending specifier is consumed by the next successful local creation. Intervening operations do not consume it.
A private Dict field cannot be selected by source-text member selection from outside the Dict (.NAME, .@NAME, .!NAME); ordinal access, schema queries and callField still reach it. Private marks take part in the schema of the Dict: two schemas that differ only in the privacy of a field are not same.
A private name remains available for lookup inside its defining module, but it is not directly imported into another module.
Behavior
- If another private specifier is already pending in the same scope, using
privateagain is invalid. - After the next successful local creation, the pending private specifier is cleared.
- A pending private specifier also applies to successful
exportFunction,importFunction, andimportVariablename creation. - If the scope ends before the pending private specifier is consumed, the program is invalid.
- Pending
overloadorvirtualspecifiers coexist with the pending private specifier. - A private overload cannot be imported directly, but it participates in overload lookup after the module has been loaded through some other public name.
Example
privateExample.mpl
private hidden: 1;
private overload virtual hiddenHelper: 3;
virtual visible: 2;
showHidden: [
"-- private name remains usable inside the module --" printCompilerMessage
hidden printStack _:;
];
test.mpl
"privateExample.showHidden" use
"privateExample.visible" use
{} 0 {} [
showHidden
"-- following created name is public again --" printCompilerMessage
visible printStack _:;
"-- private overload still participates after module load --" printCompilerMessage
hiddenHelper printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- private name remains usable inside the module --
Int32 Cref
-- following created name is public again --
2
-- private overload still participates after module load --
3
See also
fieldIsPrivatebuiltin(schema ordinal -- isPrivate)Visibility test for one selected Dict field.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; pendingprivateapplies there.importFunctionbuiltin(inputsSchema output options name --)Declares or imports a named function with the supplied signature; pendingprivateapplies there.importVariablebuiltin(schema name --)Creates a local that refers to external variable storage; pendingprivateapplies there.overloadbuiltin(--)Marks the next local created byNAME: ...;ordefas participating in overload resolution.virtualbuiltin(--)Marks the next local created byNAME: ...;ordefas static;virtualis the historical name for this declaration modifier.