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.

uCalc = [uCalc]

Property

Product: 

Fast Math Parser

Class: 

DataType

Retrieves the parent uCalc instance that owns and manages this data type definition.

Remarks

This method returns the parent uCalc instance to which the current DataType object belongs.

🎯 Core Concept: Instance-Specific Types

In uCalc, every component—including variables, functions, and data types—exists within the context of a specific uCalc engine instance. This architecture is fundamental to creating isolated, sandboxed environments. For example, the String data type in uc1 can have different properties or formatters than the String data type in uc2.

The DataType.uCalc() method provides the crucial link back to this parent environment. If you have a reference to a DataType object, you can use this method to access the full scope of its owner, allowing you to:

  • Evaluate expressions within that specific context.
  • Define new variables of that type.
  • Look up other items (functions, operators) that belong to the same instance.

💡 Comparative Analysis

  • vs. Native .NET/C# Type Objects: In .NET, a Type object retrieved via typeof(int) or myVar.GetType() is global to the AppDomain. It has no concept of an "owner" instance. uCalc's model is different: its data types are instance-specific. This allows for powerful customization on a per-instance basis, and DataType.uCalc() is the mechanism to navigate from a type definition back to its specific execution environment.

  • vs. Other Expression Engines: Simpler evaluators often have a single, global type system. uCalc's instance-based approach provides superior encapsulation and is essential for applications that need to run multiple, independent calculation environments simultaneously (e.g., in a multi-threaded server or a plugin-based architecture).

Examples

A succinct example demonstrating how to retrieve the parent uCalc instance from a DataType object.
				
					using uCalcSoftware;

var uc = new uCalc();
uc.Description = "Main uCalc Instance";

// Get the DataType object for Int32
var intType = uc.DataTypeOf(BuiltInType.Integer_32);

// Use the .uCalc() method to get back to the parent instance and read its description.
Console.WriteLine(intType.uCalc.Description);
				
			
Main uCalc Instance
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.Description("Main uCalc Instance");

   // Get the DataType object for Int32
   auto intType = uc.DataTypeOf(BuiltInType::Integer_32);

   // Use the .uCalc() method to get back to the parent instance and read its description.
   cout << intType.uCalc().Description() << endl;
}
				
			
Main uCalc Instance
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.Description = "Main uCalc Instance"
      
      '// Get the DataType object for Int32
      Dim intType = uc.DataTypeOf(BuiltInType.Integer_32)
      
      '// Use the .uCalc() method to get back to the parent instance and read its description.
      Console.WriteLine(intType.uCalc.Description)
   End Sub
End Module
				
			
Main uCalc Instance
Internal test to confirm instance isolation by proving a DataType is strictly bound to its parent uCalc instance.
				
					using uCalcSoftware;

var uc = new uCalc();
// Create two completely separate uCalc instances.
var uc1 = new uCalc();
uc1.DefineVariable("x = 100");

var uc2 = new uCalc();
uc2.DefineVariable("x = 200");

// Get the DataType for 'Int' from the *first* instance.
var intType_from_uc1 = uc1.DataTypeOf("Int");

// Use the .uCalc() method to get the parent instance.
// This should be uc1, so evaluating 'x' should yield 100.
var parent = intType_from_uc1.uCalc;
Console.WriteLine($"Parent of intType_from_uc1 evaluates 'x' to: {parent.Eval("x")}");

// Get the DataType for 'Int' from the *second* instance.
var intType_from_uc2 = uc2.DataTypeOf("Int");

// This should be uc2, so evaluating 'x' should yield 200.
parent = intType_from_uc2.uCalc;
Console.WriteLine($"Parent of intType_from_uc2 evaluates 'x' to: {parent.Eval("x")}");
				
			
Parent of intType_from_uc1 evaluates 'x' to: 100
Parent of intType_from_uc2 evaluates 'x' to: 200
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Create two completely separate uCalc instances.
   uCalc uc1;
   uc1.DefineVariable("x = 100");

   uCalc uc2;
   uc2.DefineVariable("x = 200");

   // Get the DataType for 'Int' from the *first* instance.
   auto intType_from_uc1 = uc1.DataTypeOf("Int");

   // Use the .uCalc() method to get the parent instance.
   // This should be uc1, so evaluating 'x' should yield 100.
   auto parent = intType_from_uc1.uCalc();
   cout << "Parent of intType_from_uc1 evaluates 'x' to: " << parent.Eval("x") << endl;

   // Get the DataType for 'Int' from the *second* instance.
   auto intType_from_uc2 = uc2.DataTypeOf("Int");

   // This should be uc2, so evaluating 'x' should yield 200.
   parent = intType_from_uc2.uCalc();
   cout << "Parent of intType_from_uc2 evaluates 'x' to: " << parent.Eval("x") << endl;
}
				
			
Parent of intType_from_uc1 evaluates 'x' to: 100
Parent of intType_from_uc2 evaluates 'x' to: 200
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Create two completely separate uCalc instances.
      Dim uc1 As New uCalc()
      uc1.DefineVariable("x = 100")
      
      Dim uc2 As New uCalc()
      uc2.DefineVariable("x = 200")
      
      '// Get the DataType for 'Int' from the *first* instance.
      Dim intType_from_uc1 = uc1.DataTypeOf("Int")
      
      '// Use the .uCalc() method to get the parent instance.
      '// This should be uc1, so evaluating 'x' should yield 100.
      Dim parent = intType_from_uc1.uCalc
      Console.WriteLine($"Parent of intType_from_uc1 evaluates 'x' to: {parent.Eval("x")}")
      
      '// Get the DataType for 'Int' from the *second* instance.
      Dim intType_from_uc2 = uc2.DataTypeOf("Int")
      
      '// This should be uc2, so evaluating 'x' should yield 200.
      parent = intType_from_uc2.uCalc
      Console.WriteLine($"Parent of intType_from_uc2 evaluates 'x' to: {parent.Eval("x")}")
   End Sub
End Module
				
			
Parent of intType_from_uc1 evaluates 'x' to: 100
Parent of intType_from_uc2 evaluates 'x' to: 200