uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
Description = [string]
Property
Product:
Class:
Retrieves or assigns a user-defined text description to a uCalc object, useful for attaching metadata and for debugging.
Remarks
The Description method provides a powerful way to attach arbitrary string metadata to most uCalc objects. This is invaluable for debugging, creating self-documenting configurations, and identifying specific components at runtime.
⚙️ Getter and Setter Behavior
This method is overloaded to function as both a getter and a setter:
- Getter: When called with no arguments,
Description()returns the current description of the object. If no description has been set, it returns an empty string. - Setter: When called with a string argument,
Description("your text")sets the object's description. The setter supports a fluent interface, meaning it returns a reference to the object itself, allowing you to chain other method calls.
🎯 Supported Objects
A consistent description mechanism is available across a wide range of uCalc objects, including:
- uCalc (the main instance)
- Transformer
PassRule- Item (functions, operators, variables)
Token- Tokens (the token collection)
This consistency allows you to build robust logging and debugging tools for complex parsing and transformation tasks.
🤔 Why is this useful? (Comparison)
Without a built-in mechanism, developers often resort to external structures to track object metadata:
- External Dictionaries: Managing a dictionary to map objects to strings can be cumbersome and lead to synchronization issues if objects are created or destroyed dynamically.
- Wrapper Classes: Creating custom classes just to add a description field adds unnecessary boilerplate code.
- Code Comments: Comments are static and cannot be accessed programmatically at runtime.
uCalc's integrated Description method avoids these issues by keeping the metadata tightly coupled with the object it describes. You can easily iterate through a collection of rules or tokens and print their intended purpose, which is especially useful when debugging why a particular input string was matched (or not matched). See the practical example below for a demonstration.
Examples
A quick example demonstrating how to set and get a description on a variable.
using uCalcSoftware;
var uc = new uCalc();
// Define a variable and chain the Description() call to set metadata
var myVar = uc.DefineVariable("x = 10").SetDescription("Stores the current iteration count.");
// Retrieve and display the description
Console.WriteLine($"Description for 'x': {myVar.Description}");
Description for 'x': Stores the current iteration count. using uCalcSoftware; var uc = new uCalc(); // Define a variable and chain the Description() call to set metadata var myVar = uc.DefineVariable("x = 10").SetDescription("Stores the current iteration count."); // Retrieve and display the description Console.WriteLine($"Description for 'x': {myVar.Description}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Define a variable and chain the Description() call to set metadata
auto myVar = uc.DefineVariable("x = 10").SetDescription("Stores the current iteration count.");
// Retrieve and display the description
cout << "Description for 'x': " << myVar.Description() << endl;
}
Description for 'x': Stores the current iteration count. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Define a variable and chain the Description() call to set metadata auto myVar = uc.DefineVariable("x = 10").SetDescription("Stores the current iteration count."); // Retrieve and display the description cout << "Description for 'x': " << myVar.Description() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Define a variable and chain the Description() call to set metadata
Dim myVar = uc.DefineVariable("x = 10").SetDescription("Stores the current iteration count.")
'// Retrieve and display the description
Console.WriteLine($"Description for 'x': {myVar.Description}")
End Sub
End Module
Description for 'x': Stores the current iteration count. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Define a variable and chain the Description() call to set metadata Dim myVar = uc.DefineVariable("x = 10").SetDescription("Stores the current iteration count.") '// Retrieve and display the description Console.WriteLine($"Description for 'x': {myVar.Description}") End Sub End Module
uCalc Description
using uCalcSoftware;
var uc = new uCalc();
uc.Description = "This is the main uCalc object";
var t = uc.NewTransformer();
Console.WriteLine(t.Tokens.uCalc.Description);
This is the main uCalc object using uCalcSoftware; var uc = new uCalc(); uc.Description = "This is the main uCalc object"; var t = uc.NewTransformer(); Console.WriteLine(t.Tokens.uCalc.Description);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uc.Description("This is the main uCalc object");
auto t = uc.NewTransformer();
cout << t.Tokens().uCalc().Description() << endl;
}
This is the main uCalc object #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uc.Description("This is the main uCalc object"); auto t = uc.NewTransformer(); cout << t.Tokens().uCalc().Description() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.Description = "This is the main uCalc object"
Dim t = uc.NewTransformer()
Console.WriteLine(t.Tokens.uCalc.Description)
End Sub
End Module
This is the main uCalc object Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.Description = "This is the main uCalc object" Dim t = uc.NewTransformer() Console.WriteLine(t.Tokens.uCalc.Description) End Sub End Module
Sets and retrieves a description for the main uCalc object.
using uCalcSoftware;
var uc = new uCalc();
// Assign a description to the main uCalc instance
uc.Description = "Primary evaluator for financial calculations";
// Retrieve and print the description
Console.WriteLine(uc.Description);
Primary evaluator for financial calculations using uCalcSoftware; var uc = new uCalc(); // Assign a description to the main uCalc instance uc.Description = "Primary evaluator for financial calculations"; // Retrieve and print the description Console.WriteLine(uc.Description);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Assign a description to the main uCalc instance
uc.Description("Primary evaluator for financial calculations");
// Retrieve and print the description
cout << uc.Description() << endl;
}
Primary evaluator for financial calculations #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Assign a description to the main uCalc instance uc.Description("Primary evaluator for financial calculations"); // Retrieve and print the description cout << uc.Description() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Assign a description to the main uCalc instance
uc.Description = "Primary evaluator for financial calculations"
'// Retrieve and print the description
Console.WriteLine(uc.Description)
End Sub
End Module
Primary evaluator for financial calculations Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Assign a description to the main uCalc instance uc.Description = "Primary evaluator for financial calculations" '// Retrieve and print the description Console.WriteLine(uc.Description) End Sub End Module