uCalc API Version: 2.1.3-preview.2 Released: 6/17/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: 

Fast Math Parser

Class: 

Item

Checks if a uCalc item possesses a specific characteristic, such as being a function, variable, or read-only.

Syntax

IsProperty(ItemIs)

Parameters

itemProperty
ItemIs
The property to check for, specified as a member of the `ItemIs` enumeration.

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:

PropertyIsProperty(ItemIs::...)Returns true for...
FunctionFunctionItems created with DefineFunction.
VariableVariableItems created with DefineVariable.
OperatorOperatorItems created with DefineOperator.
Read-OnlyLockedConstants or items that cannot be modified.
Non-ExistentNotFoundAn empty item handle returned by ItemOf when a search fails.
InfixInfixAn operator that appears between two operands (e.g., * in 3*4).
PrefixPrefixAn operator that appears before an operand (e.g., - in -5).
PostfixPostfixAn operator that appears between two operands (e.g., ++ in x++).
Data typeDataTypeA data type.
ArrayArrayAn array.
Error handlerErrorHandlerAn error handler.
TransformerTransformerA transformer.
FormatterFormatA string formatter.
Function or OperatorFunctionOrOperatorEither a function or a operator.
Right to left associativeRightToLeftAn operator that is right-to-left-associative.
Address ownerAddressOwnerFalse when the address is owned by the host program.
AliasAliasAn alias for another item.
SearchSearchA search item.
Case-sensitiveCaseSensitiveA case-sensitive item.
Quoted textQuotedTextQuoted 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.IsStatic or typeof(MyClass).IsInterface. uCalc's IsProperty is 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's typeof check an object's class or primitive type. IsProperty is fundamentally different because it checks for features or flags. An Item is always an Item, 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
				
					#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;
}
				
			
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
				
			
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
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

---
				
					#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");

}
				
			
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
				
			
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

---