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.
IsProperty(ItemIs)
Method
Product:
Class:
Checks if a uCalc item possesses a specific characteristic, such as being a function, variable, or read-only.
Syntax
Parameters
Return
bool
Returns true if the item has the specified property; otherwise, false.
Remarks
🧐 Introspection with IsProperty
The IsProperty method is the primary tool for runtime introspection of a uCalc Item. It allows you to check if an item possesses a specific characteristic or "flag," enabling you to write code that adapts to the type and state of any defined symbol.
This is more granular than a simple type check. An Item can have multiple properties simultaneously. For instance, an infix operator will have the Operator, Infix, and FunctionOrOperator properties, all of which will return true when checked.
⚙️ Common Properties
Use this function with members of the ItemIs enum to check for common characteristics:
| Property | IsProperty(ItemIs::...) | Returns true for... |
|---|---|---|
| Function | Function | Items created with DefineFunction. |
| Variable | Variable | Items created with DefineVariable. |
| Operator | Operator | Items created with DefineOperator. |
| Read-Only | Locked | Constants or items that cannot be modified. |
| Non-Existent | NotFound | An empty item handle returned by ItemOf when a search fails. |
| Infix | Infix | An operator that appears between two operands (e.g., * in 3*4). |
| Prefix | Prefix | An operator that appears before an operand (e.g., - in -5). |
| Postfix | Postfix | An operator that appears between two operands (e.g., ++ in x++). |
| Data type | DataType | A data type. |
| Array | Array | An array. |
| Error handler | ErrorHandler | An error handler. |
| Transformer | Transformer | A transformer. |
| Formatter | Format | A string formatter. |
| Function or Operator | FunctionOrOperator | Either a function or a operator. |
| Right to left associative | RightToLeft | An operator that is right-to-left-associative. |
| Address owner | AddressOwner | False when the address is owned by the host program. |
| Alias | Alias | An alias for another item. |
| Search | Search | A search item. |
| Case-sensitive | CaseSensitive | A case-sensitive item. |
| Quoted text | QuotedText | Quoted text. |
💡 Why uCalc? (Comparative Analysis)
This method provides a more detailed level of introspection than typical type-checking systems.
vs. C#/.NET Reflection: In .NET, you might check
MethodInfo.IsStaticortypeof(MyClass).IsInterface. uCalc'sIsPropertyis analogous but tailored to its own, more dynamic object model. The key difference is that uCalc's properties describe an item's role and state within the parser (Infix,Locked) rather than just its underlying class.vs. Dynamic Languages (Python/JavaScript): Functions like Python's
isinstance()or JavaScript'stypeofcheck an object's class or primitive type.IsPropertyis fundamentally different because it checks for features or flags. AnItemis always anItem, but its properties define what it does. This allows for a more flexible and powerful system where characteristics are not rigidly tied to a class hierarchy.
This feature-based introspection makes it easy to build powerful tools like custom debuggers, expression visualizers, or intelligent autocompletion engines on top of the uCalc engine.
Examples
Determining whether items are functions, or arrays, etc.
using uCalcSoftware;
var uc = new uCalc();
uc.DefineVariable("MyVar");
Console.WriteLine($"{uc.EvalStr("'Cos is a function? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Function)}");
Console.WriteLine($"{uc.EvalStr("'Cos is a variable? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Variable)}");
Console.WriteLine($"{uc.EvalStr("'Cos is an operator? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Operator)}");
Console.WriteLine($"{uc.EvalStr("'MyVar is a function? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Function)}");
Console.WriteLine($"{uc.EvalStr("'MyVar is a variable? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Variable)}");
Console.WriteLine($"{uc.EvalStr("'MyVar is an operator? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Operator)}");
Console.WriteLine($"{uc.EvalStr("'+ is a function? '")}{uc.ItemOf("+").IsProperty(ItemIs.Function)}");
Console.WriteLine($"{uc.EvalStr("'+ is a variable? '")}{uc.ItemOf("+").IsProperty(ItemIs.Variable)}");
Console.WriteLine($"{uc.EvalStr("'+ is an operator? '")}{uc.ItemOf("+").IsProperty(ItemIs.Operator)}");
Console.WriteLine($"{uc.EvalStr("'Cos not found? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.NotFound)}");
Console.WriteLine($"{uc.EvalStr("'XYZABC not found? '")}{uc.ItemOf("XYZABC").IsProperty(ItemIs.NotFound)}");
Cos is a function? True
Cos is a variable? False
Cos is an operator? False
MyVar is a function? False
MyVar is a variable? True
MyVar is an operator? False
+ is a function? False
+ is a variable? False
+ is an operator? True
Cos not found? False
XYZABC not found? True using uCalcSoftware; var uc = new uCalc(); uc.DefineVariable("MyVar"); Console.WriteLine($"{uc.EvalStr("'Cos is a function? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Function)}"); Console.WriteLine($"{uc.EvalStr("'Cos is a variable? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Variable)}"); Console.WriteLine($"{uc.EvalStr("'Cos is an operator? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Operator)}"); Console.WriteLine($"{uc.EvalStr("'MyVar is a function? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Function)}"); Console.WriteLine($"{uc.EvalStr("'MyVar is a variable? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Variable)}"); Console.WriteLine($"{uc.EvalStr("'MyVar is an operator? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Operator)}"); Console.WriteLine($"{uc.EvalStr("'+ is a function? '")}{uc.ItemOf("+").IsProperty(ItemIs.Function)}"); Console.WriteLine($"{uc.EvalStr("'+ is a variable? '")}{uc.ItemOf("+").IsProperty(ItemIs.Variable)}"); Console.WriteLine($"{uc.EvalStr("'+ is an operator? '")}{uc.ItemOf("+").IsProperty(ItemIs.Operator)}"); Console.WriteLine($"{uc.EvalStr("'Cos not found? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.NotFound)}"); Console.WriteLine($"{uc.EvalStr("'XYZABC not found? '")}{uc.ItemOf("XYZABC").IsProperty(ItemIs.NotFound)}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uc.DefineVariable("MyVar");
cout << uc.EvalStr("'Cos is a function? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Function)) << endl;
cout << uc.EvalStr("'Cos is a variable? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Variable)) << endl;
cout << uc.EvalStr("'Cos is an operator? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Operator)) << endl;
cout << uc.EvalStr("'MyVar is a function? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Function)) << endl;
cout << uc.EvalStr("'MyVar is a variable? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Variable)) << endl;
cout << uc.EvalStr("'MyVar is an operator? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Operator)) << endl;
cout << uc.EvalStr("'+ is a function? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Function)) << endl;
cout << uc.EvalStr("'+ is a variable? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Variable)) << endl;
cout << uc.EvalStr("'+ is an operator? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Operator)) << endl;
cout << uc.EvalStr("'Cos not found? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::NotFound)) << endl;
cout << uc.EvalStr("'XYZABC not found? '") << tf(uc.ItemOf("XYZABC").IsProperty(ItemIs::NotFound)) << endl;
}
Cos is a function? True
Cos is a variable? False
Cos is an operator? False
MyVar is a function? False
MyVar is a variable? True
MyVar is an operator? False
+ is a function? False
+ is a variable? False
+ is an operator? True
Cos not found? False
XYZABC not found? True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uc.DefineVariable("MyVar"); cout << uc.EvalStr("'Cos is a function? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Function)) << endl; cout << uc.EvalStr("'Cos is a variable? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Variable)) << endl; cout << uc.EvalStr("'Cos is an operator? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::Operator)) << endl; cout << uc.EvalStr("'MyVar is a function? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Function)) << endl; cout << uc.EvalStr("'MyVar is a variable? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Variable)) << endl; cout << uc.EvalStr("'MyVar is an operator? '") << tf(uc.ItemOf("MyVar").IsProperty(ItemIs::Operator)) << endl; cout << uc.EvalStr("'+ is a function? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Function)) << endl; cout << uc.EvalStr("'+ is a variable? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Variable)) << endl; cout << uc.EvalStr("'+ is an operator? '") << tf(uc.ItemOf("+").IsProperty(ItemIs::Operator)) << endl; cout << uc.EvalStr("'Cos not found? '") << tf(uc.ItemOf("Cos").IsProperty(ItemIs::NotFound)) << endl; cout << uc.EvalStr("'XYZABC not found? '") << tf(uc.ItemOf("XYZABC").IsProperty(ItemIs::NotFound)) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.DefineVariable("MyVar")
Console.WriteLine($"{uc.EvalStr("'Cos is a function? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Function)}")
Console.WriteLine($"{uc.EvalStr("'Cos is a variable? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Variable)}")
Console.WriteLine($"{uc.EvalStr("'Cos is an operator? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Operator)}")
Console.WriteLine($"{uc.EvalStr("'MyVar is a function? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Function)}")
Console.WriteLine($"{uc.EvalStr("'MyVar is a variable? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Variable)}")
Console.WriteLine($"{uc.EvalStr("'MyVar is an operator? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Operator)}")
Console.WriteLine($"{uc.EvalStr("'+ is a function? '")}{uc.ItemOf("+").IsProperty(ItemIs.Function)}")
Console.WriteLine($"{uc.EvalStr("'+ is a variable? '")}{uc.ItemOf("+").IsProperty(ItemIs.Variable)}")
Console.WriteLine($"{uc.EvalStr("'+ is an operator? '")}{uc.ItemOf("+").IsProperty(ItemIs.Operator)}")
Console.WriteLine($"{uc.EvalStr("'Cos not found? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.NotFound)}")
Console.WriteLine($"{uc.EvalStr("'XYZABC not found? '")}{uc.ItemOf("XYZABC").IsProperty(ItemIs.NotFound)}")
End Sub
End Module
Cos is a function? True
Cos is a variable? False
Cos is an operator? False
MyVar is a function? False
MyVar is a variable? True
MyVar is an operator? False
+ is a function? False
+ is a variable? False
+ is an operator? True
Cos not found? False
XYZABC not found? True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.DefineVariable("MyVar") Console.WriteLine($"{uc.EvalStr("'Cos is a function? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Function)}") Console.WriteLine($"{uc.EvalStr("'Cos is a variable? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Variable)}") Console.WriteLine($"{uc.EvalStr("'Cos is an operator? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.Operator)}") Console.WriteLine($"{uc.EvalStr("'MyVar is a function? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Function)}") Console.WriteLine($"{uc.EvalStr("'MyVar is a variable? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Variable)}") Console.WriteLine($"{uc.EvalStr("'MyVar is an operator? '")}{uc.ItemOf("MyVar").IsProperty(ItemIs.Operator)}") Console.WriteLine($"{uc.EvalStr("'+ is a function? '")}{uc.ItemOf("+").IsProperty(ItemIs.Function)}") Console.WriteLine($"{uc.EvalStr("'+ is a variable? '")}{uc.ItemOf("+").IsProperty(ItemIs.Variable)}") Console.WriteLine($"{uc.EvalStr("'+ is an operator? '")}{uc.ItemOf("+").IsProperty(ItemIs.Operator)}") Console.WriteLine($"{uc.EvalStr("'Cos not found? '")}{uc.ItemOf("Cos").IsProperty(ItemIs.NotFound)}") Console.WriteLine($"{uc.EvalStr("'XYZABC not found? '")}{uc.ItemOf("XYZABC").IsProperty(ItemIs.NotFound)}") End Sub End Module
Determining properties of an expression part
using uCalcSoftware;
var uc = new uCalc();
static void ItemCallback(uCalc.Callback cb) {
Console.WriteLine($"Name: {cb.Item.Name}");
Console.WriteLine($"Data type: {cb.Item.DataType.Name}");
Console.WriteLine($"Param count: {cb.Item.Count}");
Console.Write("Procedure type: ");
if (cb.Item.IsProperty(ItemIs.Operator)) {
Console.WriteLine("Operator");
} else if (cb.Item.IsProperty(ItemIs.Function)) {
Console.WriteLine("Function");
}
Console.WriteLine(cb.Item.Text);
Console.WriteLine(cb.Item.Description);
Console.WriteLine("---");
}
uc.DefineFunction("AAA() As Double", ItemCallback).Description = "Does this and that";
uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description = "Does something else";
uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity.LeftToRight, ItemCallback);
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Function: AAA() As Double
Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Function: BBB(x, y, z) As String
Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Operator: {x} CCC {y} As Int32
--- using uCalcSoftware; var uc = new uCalc(); static void ItemCallback(uCalc.Callback cb) { Console.WriteLine($"Name: {cb.Item.Name}"); Console.WriteLine($"Data type: {cb.Item.DataType.Name}"); Console.WriteLine($"Param count: {cb.Item.Count}"); Console.Write("Procedure type: "); if (cb.Item.IsProperty(ItemIs.Operator)) { Console.WriteLine("Operator"); } else if (cb.Item.IsProperty(ItemIs.Function)) { Console.WriteLine("Function"); } Console.WriteLine(cb.Item.Text); Console.WriteLine(cb.Item.Description); Console.WriteLine("---"); } uc.DefineFunction("AAA() As Double", ItemCallback).Description = "Does this and that"; uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description = "Does something else"; uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity.LeftToRight, ItemCallback); uc.EvalStr("AAA()"); uc.EvalStr("BBB(9, 8, 7)"); uc.EvalStr("5 CCC 4");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call ItemCallback(uCalcBase::Callback cb) {
cout << "Name: " << cb.Item().Name() << endl;
cout << "Data type: " << cb.Item().DataType().Name() << endl;
cout << "Param count: " << cb.Item().Count() << endl;
cout << "Procedure type: ";
if (cb.Item().IsProperty(ItemIs::Operator)) {
cout << "Operator" << endl;
} else if (cb.Item().IsProperty(ItemIs::Function)) {
cout << "Function" << endl;
}
cout << cb.Item().Text() << endl;
cout << cb.Item().Description() << endl;
cout << "---" << endl;
}
int main() {
uCalc uc;
uc.DefineFunction("AAA() As Double", ItemCallback).Description("Does this and that");
uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description("Does something else");
uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity::LeftToRight, ItemCallback);
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Function: AAA() As Double
Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Function: BBB(x, y, z) As String
Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Operator: {x} CCC {y} As Int32
--- #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call ItemCallback(uCalcBase::Callback cb) { cout << "Name: " << cb.Item().Name() << endl; cout << "Data type: " << cb.Item().DataType().Name() << endl; cout << "Param count: " << cb.Item().Count() << endl; cout << "Procedure type: "; if (cb.Item().IsProperty(ItemIs::Operator)) { cout << "Operator" << endl; } else if (cb.Item().IsProperty(ItemIs::Function)) { cout << "Function" << endl; } cout << cb.Item().Text() << endl; cout << cb.Item().Description() << endl; cout << "---" << endl; } int main() { uCalc uc; uc.DefineFunction("AAA() As Double", ItemCallback).Description("Does this and that"); uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description("Does something else"); uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity::LeftToRight, ItemCallback); uc.EvalStr("AAA()"); uc.EvalStr("BBB(9, 8, 7)"); uc.EvalStr("5 CCC 4"); }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub ItemCallback(ByVal cb As uCalc.Callback)
Console.WriteLine($"Name: {cb.Item.Name}")
Console.WriteLine($"Data type: {cb.Item.DataType.Name}")
Console.WriteLine($"Param count: {cb.Item.Count}")
Console.Write("Procedure type: ")
If cb.Item.IsProperty(ItemIs.Operator) Then
Console.WriteLine("Operator")
ElseIf cb.Item.IsProperty(ItemIs.Function ) Then
Console.WriteLine("Function")
End If
Console.WriteLine(cb.Item.Text)
Console.WriteLine(cb.Item.Description)
Console.WriteLine("---")
End Sub
Public Sub Main()
Dim uc As New uCalc()
uc.DefineFunction("AAA() As Double", AddressOf ItemCallback).Description = "Does this and that"
uc.DefineFunction("BBB(x, y, z) As String", AddressOf ItemCallback).Description = "Does something else"
uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity.LeftToRight, AddressOf ItemCallback)
uc.EvalStr("AAA()")
uc.EvalStr("BBB(9, 8, 7)")
uc.EvalStr("5 CCC 4")
End Sub
End Module
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Function: AAA() As Double
Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Function: BBB(x, y, z) As String
Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Operator: {x} CCC {y} As Int32
--- Imports System Imports uCalcSoftware Public Module Program Public Sub ItemCallback(ByVal cb As uCalc.Callback) Console.WriteLine($"Name: {cb.Item.Name}") Console.WriteLine($"Data type: {cb.Item.DataType.Name}") Console.WriteLine($"Param count: {cb.Item.Count}") Console.Write("Procedure type: ") If cb.Item.IsProperty(ItemIs.Operator) Then Console.WriteLine("Operator") ElseIf cb.Item.IsProperty(ItemIs.Function ) Then Console.WriteLine("Function") End If Console.WriteLine(cb.Item.Text) Console.WriteLine(cb.Item.Description) Console.WriteLine("---") End Sub Public Sub Main() Dim uc As New uCalc() uc.DefineFunction("AAA() As Double", AddressOf ItemCallback).Description = "Does this and that" uc.DefineFunction("BBB(x, y, z) As String", AddressOf ItemCallback).Description = "Does something else" uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity.LeftToRight, AddressOf ItemCallback) uc.EvalStr("AAA()") uc.EvalStr("BBB(9, 8, 7)") uc.EvalStr("5 CCC 4") End Sub End Module