Struct RuntimeSemanticsEvaluationResult<TValue>
Represents the result of an evaluation whose result type is known statically: the same outcome as
RuntimeSemanticsEvaluationResult, with the VBTypedValue it produces
named by TValue.
public readonly record struct RuntimeSemanticsEvaluationResult<TValue> : IRuntimeSemanticsEvaluationResult, IEquatable<RuntimeSemanticsEvaluationResult<TValue>> where TValue : VBTypedValue
Type Parameters
TValueThe VBTypedValue a successful evaluation produces.
- Implements
- Inherited Members
Remarks
This is how a standard-library member declaration states its VBA return type
(RD-VBAL §6.1: "the symbols shall carry the appropriate return type
metadata"). Naming it in the signature rather than restating it in an attribute means the
declaration and the implementation cannot disagree - an implementation of Hex$ that returns
anything but a VBStringValue does not compile - and a symbol
provider reads the declared type back off the signature.
A member returning nothing - a VBA Sub, or a Property Let/Set - is declared
with the non-generic RuntimeSemanticsEvaluationResult instead, so the presence of a
return type is itself part of the declaration. Its declared type is
VBVoidType and the value it yields is
Void - not
VBEmptyValue, which is a real Variant subtype source can
see (IsEmpty, VarType, a Let-coercion to 0); the result of a Sub is
nothing source can see anything about at all.
👉 An enumeration or a class is not expressible as a TValue: every
value of one is a VBLongValue or a
VBObjectValue respectively, which is what an implementation
produces and so what this names. Those members state the type VBA source sees with
ReturnType.
Constructors
RuntimeSemanticsEvaluationResult(TValue?, IVBRaisableError?)
Represents the result of an evaluation whose result type is known statically: the same outcome as
RuntimeSemanticsEvaluationResult, with the VBTypedValue it produces
named by TValue.
public RuntimeSemanticsEvaluationResult(TValue? Result, IVBRaisableError? ErrorInfo)
Parameters
ResultTValueThe result of the evaluation, if one was produced.
ErrorInfoIVBRaisableErrorThe error metadata for the run-time error to be reported, if applicable.
Remarks
This is how a standard-library member declaration states its VBA return type
(RD-VBAL §6.1: "the symbols shall carry the appropriate return type
metadata"). Naming it in the signature rather than restating it in an attribute means the
declaration and the implementation cannot disagree - an implementation of Hex$ that returns
anything but a VBStringValue does not compile - and a symbol
provider reads the declared type back off the signature.
A member returning nothing - a VBA Sub, or a Property Let/Set - is declared
with the non-generic RuntimeSemanticsEvaluationResult instead, so the presence of a
return type is itself part of the declaration. Its declared type is
VBVoidType and the value it yields is
Void - not
VBEmptyValue, which is a real Variant subtype source can
see (IsEmpty, VarType, a Let-coercion to 0); the result of a Sub is
nothing source can see anything about at all.
👉 An enumeration or a class is not expressible as a TValue: every
value of one is a VBLongValue or a
VBObjectValue respectively, which is what an implementation
produces and so what this names. Those members state the type VBA source sees with
ReturnType.
Properties
ErrorInfo
The error metadata for the run-time error to be reported, if applicable.
public IVBRaisableError? ErrorInfo { get; init; }
Property Value
IsError
true if the evaluation semantically yields a runtime error.
public bool IsError { get; }
Property Value
Remarks
👉 This value represents a specified, consistent state where program execution resumes in a controlled error state.
A result value may or may not have been assigned before the failure: most errors carry none, which is why
this asks only whether there is an error. It used to require a value too, and so answered false for
every error raised without one - which is what Error(VBRuntimeErrorInfo, VBTypedValue?)'s
own default produces.
IsInternalError
true if an evaluation strategy could not be determined.
public bool IsInternalError { get; }
Property Value
Remarks
⚠️ This value represents an unspecified, inconsistent internal state that is ultimately surfaced as an InternalError run-time error.
IsSuccess
true if the evaluation was successfully completed.
public bool IsSuccess { get; }
Property Value
Remarks
✅ This value represents a normally completed, successful evaluation.
Result
The result of the evaluation, if one was produced.
public TValue? Result { get; init; }
Property Value
- TValue
Methods
Error(IVBRaisableError, TValue?)
Creates a new (failed) RuntimeSemanticsEvaluationResult with the specified IVBRaisableError error information metadata.
public static RuntimeSemanticsEvaluationResult<TValue> Error(IVBRaisableError error, TValue? result = null)
Parameters
errorIVBRaisableErrorThe runtime error metadata describing the evaluation failure.
resultTValueThe result value assigned before the failure, if any.
Returns
- RuntimeSemanticsEvaluationResult<TValue>
Remarks
❌ Use this method only to signal a failed expression evaluation. A result value may still have been assigned.
InternalError()
Creates a new RuntimeSemanticsEvalutationResult without a result, and without any IVBRaisableError error metadata.
public static RuntimeSemanticsEvaluationResult<TValue> InternalError()
Returns
- RuntimeSemanticsEvaluationResult<TValue>
Remarks
💥 This results signals a InternalError run-time error to the evaluation pipeline.
Use it only as a fallback result, when no result can be evaluated for a given effective type.
Success(TValue)
Creates a new (successful) RuntimeSemanticsEvaluationResult with the specified evaluation result.
public static RuntimeSemanticsEvaluationResult<TValue> Success(TValue result)
Parameters
resultTValueThe successfully evaluated runtime semantics evaluation result.
Returns
- RuntimeSemanticsEvaluationResult<TValue>
Remarks
✅ Use this method only to signal a successully evaluated expression result.
Operators
implicit operator RuntimeSemanticsEvaluationResult(RuntimeSemanticsEvaluationResult<TValue>)
Widens the result to one whose result type is not stated, discarding nothing.
public static implicit operator RuntimeSemanticsEvaluationResult(RuntimeSemanticsEvaluationResult<TValue> result)
Parameters
resultRuntimeSemanticsEvaluationResult<TValue>The result to widen.