Class Surrogate
Provides capability to construct an object that acts as another, even when the other object doesn't exist yet.
Until an object actually starts existing, the only thing you cannot do with a surrogate, is call it. Reading slots produces more surrogates. Can be used to resolve cyclic dependencies.
Functions
Surrogate:New (accessor) | Creates a surrogate for function that returns the object or nil . |
Surrogate.isSurrogate (o) | Checks, whether the given object is a Surrogate. |
Functions
- Surrogate.isSurrogate (o)
-
Checks, whether the given object is a Surrogate.
Even if the instance itself is an instance of Surrogate, it will return false if the object for whom the surrogate was created already exists.
Parameters:
- o Object to check.
Returns:
-
bool
true
if it is a surrogate,false
if it is an actual object - Surrogate:New (accessor)
-
Creates a surrogate for function that returns the object or
nil
.Remarks:
-
Making surrogates to surrogate is not supported.
Parameters:
- accessor func Function that attempts to find the object the surrogate is made for.
Returns:
-
Surrogate
The created surrogate