uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Changes the name of an existing symbol, such as a variable, function, or operator, at runtime.
Returns the current Item instance to allow for method chaining.
The Rename method provides a direct, efficient way to change the identifier of any named Item within the uCalc engine at runtime. This is a destructive operation: the original name is removed from the symbol table and is no longer valid.
This is commonly used for refactoring, adapting syntax, or wrapping existing functions with new behavior.
By default, uCalc expressions are statically bound when parsed. If you rename a function f to g, any existing expression that was already parsed to call f will not be automatically updated and will fail if evaluated. Renaming only affects expressions that are parsed after the rename operation has occurred.
To create dynamically-updating (reactive) expressions, you must define functions and operators with the overwrite: true flag. See DefineFunction() for more details.
It's important to choose the right tool for modifying symbols. Rename should be compared with Alias and text-based transformers.
vs. Alias()
A -> B (A is no longer valid).A -> B (Both A and B are valid, pointing to the same underlying item).Rename for permanent changes or to free up a name for reuse. Use Alias to provide synonyms or for backward compatibility.Rename for simple name changes. Use a Transformer for complex structural changes that involve more than just a name (e.g., reordering parameters, changing operators).ID: 48
using uCalcSoftware;
var uc = new uCalc();
uc.DefineConstant("pi = Atan(1) * 4");
// Original Cosine behavior with Radian
Console.WriteLine(uc.EvalStr("Cos(pi)"));
Console.WriteLine(uc.EvalStr("Cos(180)"));
// Cos is renamed to CosR so that Cos can now be defined in Degree
uc.ItemOf("Cos").Rename("CosR");
uc.DefineFunction("Cos(x) = CosR(x*pi/180)");
// Now Cos is in Degree
Console.WriteLine(uc.EvalStr("Cos(pi)"));
Console.WriteLine(uc.EvalStr("Cos(180)"));
// This is the original function now named CosR
Console.WriteLine(uc.EvalStr("CosR(pi)"));
Console.WriteLine(uc.EvalStr("CosR(180)"));
// Note: Some functions may be overloaded, such as the Cos function in
// this example, which has a definition for Double and another for Complex.
// This example renames only the Double precision version.
// You can use NextOverload() and DataType() to pinpoint the one you want
-1
-0.59846006905785
0.99849714986386
-1
-1
-0.59846006905785 using uCalcSoftware; var uc = new uCalc(); uc.DefineConstant("pi = Atan(1) * 4"); // Original Cosine behavior with Radian Console.WriteLine(uc.EvalStr("Cos(pi)")); Console.WriteLine(uc.EvalStr("Cos(180)")); // Cos is renamed to CosR so that Cos can now be defined in Degree uc.ItemOf("Cos").Rename("CosR"); uc.DefineFunction("Cos(x) = CosR(x*pi/180)"); // Now Cos is in Degree Console.WriteLine(uc.EvalStr("Cos(pi)")); Console.WriteLine(uc.EvalStr("Cos(180)")); // This is the original function now named CosR Console.WriteLine(uc.EvalStr("CosR(pi)")); Console.WriteLine(uc.EvalStr("CosR(180)")); // Note: Some functions may be overloaded, such as the Cos function in // this example, which has a definition for Double and another for Complex. // This example renames only the Double precision version. // You can use NextOverload() and DataType() to pinpoint the one you want
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uc.DefineConstant("pi = Atan(1) * 4");
// Original Cosine behavior with Radian
cout << uc.EvalStr("Cos(pi)") << endl;
cout << uc.EvalStr("Cos(180)") << endl;
// Cos is renamed to CosR so that Cos can now be defined in Degree
uc.ItemOf("Cos").Rename("CosR");
uc.DefineFunction("Cos(x) = CosR(x*pi/180)");
// Now Cos is in Degree
cout << uc.EvalStr("Cos(pi)") << endl;
cout << uc.EvalStr("Cos(180)") << endl;
// This is the original function now named CosR
cout << uc.EvalStr("CosR(pi)") << endl;
cout << uc.EvalStr("CosR(180)") << endl;
// Note: Some functions may be overloaded, such as the Cos function in
// this example, which has a definition for Double and another for Complex.
// This example renames only the Double precision version.
// You can use NextOverload() and DataType() to pinpoint the one you want
}
-1
-0.59846006905785
0.99849714986386
-1
-1
-0.59846006905785 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uc.DefineConstant("pi = Atan(1) * 4"); // Original Cosine behavior with Radian cout << uc.EvalStr("Cos(pi)") << endl; cout << uc.EvalStr("Cos(180)") << endl; // Cos is renamed to CosR so that Cos can now be defined in Degree uc.ItemOf("Cos").Rename("CosR"); uc.DefineFunction("Cos(x) = CosR(x*pi/180)"); // Now Cos is in Degree cout << uc.EvalStr("Cos(pi)") << endl; cout << uc.EvalStr("Cos(180)") << endl; // This is the original function now named CosR cout << uc.EvalStr("CosR(pi)") << endl; cout << uc.EvalStr("CosR(180)") << endl; // Note: Some functions may be overloaded, such as the Cos function in // this example, which has a definition for Double and another for Complex. // This example renames only the Double precision version. // You can use NextOverload() and DataType() to pinpoint the one you want }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.DefineConstant("pi = Atan(1) * 4")
'// Original Cosine behavior with Radian
Console.WriteLine(uc.EvalStr("Cos(pi)"))
Console.WriteLine(uc.EvalStr("Cos(180)"))
'// Cos is renamed to CosR so that Cos can now be defined in Degree
uc.ItemOf("Cos").Rename("CosR")
uc.DefineFunction("Cos(x) = CosR(x*pi/180)")
'// Now Cos is in Degree
Console.WriteLine(uc.EvalStr("Cos(pi)"))
Console.WriteLine(uc.EvalStr("Cos(180)"))
'// This is the original function now named CosR
Console.WriteLine(uc.EvalStr("CosR(pi)"))
Console.WriteLine(uc.EvalStr("CosR(180)"))
'// Note: Some functions may be overloaded, such as the Cos function in
'// this example, which has a definition for Double and another for Complex.
'// This example renames only the Double precision version.
'// You can use NextOverload() and DataType() to pinpoint the one you want
End Sub
End Module
-1
-0.59846006905785
0.99849714986386
-1
-1
-0.59846006905785 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.DefineConstant("pi = Atan(1) * 4") '// Original Cosine behavior with Radian Console.WriteLine(uc.EvalStr("Cos(pi)")) Console.WriteLine(uc.EvalStr("Cos(180)")) '// Cos is renamed to CosR so that Cos can now be defined in Degree uc.ItemOf("Cos").Rename("CosR") uc.DefineFunction("Cos(x) = CosR(x*pi/180)") '// Now Cos is in Degree Console.WriteLine(uc.EvalStr("Cos(pi)")) Console.WriteLine(uc.EvalStr("Cos(180)")) '// This is the original function now named CosR Console.WriteLine(uc.EvalStr("CosR(pi)")) Console.WriteLine(uc.EvalStr("CosR(180)")) '// Note: Some functions may be overloaded, such as the Cos function in '// this example, which has a definition for Double and another for Complex. '// This example renames only the Double precision version. '// You can use NextOverload() and DataType() to pinpoint the one you want End Sub End Module