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, bool)

Method

Product: 

Fast Math Parser

Class: 

Item

Dynamically enables or disables a behavioral property for a uCalc item, such as making it read-only or toggling its active state.

Syntax

IsProperty(ItemIs, bool)

Parameters

itemProperty
ItemIs
The property to set, specified as a member of the [ItemIs](/Reference/Enums/ItemIs) enumeration.
value
bool
A boolean indicating whether to enable (`true`) or disable (`false`) the property.

Return

Item

Returns the current Item object to allow for a fluent interface and method chaining.

Remarks

The IsProperty method acts as a setter for the boolean flags that control an Item's behavior. It allows you to dynamically modify an item's characteristics at runtime after it has been defined.

This is the setter overload; for checking a property's status, see the getter overload: IsProperty(ItemIs).

⚙️ How It Works

Properties are like switches that can be turned on (true) or off (false). By setting a property, you can alter how uCalc treats an item during parsing, evaluation, or transformation.

✨ Common Use Cases

  • Creating Constants: Make a variable read-only by setting the ItemIs::Locked property. This is a more programmatic way to achieve what DefineConstant() does.
  • Controlling Transformer Rules: Dynamically enable or disable a Transformer rule by toggling its ItemIs::Active property.
  • Configuring Behavior: Change a rule's matching logic at runtime by setting properties like ItemIs::CaseSensitive or ItemIs::RewindOnChange.

Fluent Interface

This method returns the Item object itself, which allows for a fluent interface or method chaining. You can define an item and immediately set a property on it in a single, readable line of code.

// Define a variable and immediately lock itvar pi = uc.DefineVariable("pi = 3.14159").IsProperty(ItemIs.Locked, true);

🆚 Comparative Analysis

In statically-typed languages like C#, an object's behavior is often fixed at compile time (e.g., using the readonly keyword). While reflection can be used to modify properties, it is often complex and slow.

In dynamic languages like Python, you can change object attributes freely (my_obj.is_active = False), but this lacks the structured, enumerated property system of uCalc.

uCalc's IsProperty method provides the best of both worlds: the flexibility of a dynamic language with the clarity and safety of an enumerated property system (ItemIs), all accessible at runtime.

Examples

Changing an item's property
				
					using uCalcSoftware;

var uc = new uCalc();
var MyVar = uc.DefineVariable("x = 100");
Console.WriteLine(uc.EvalStr("x"));

uc.EvalStr("x = 200");
Console.WriteLine(uc.EvalStr("x")); // x can change here

// Locking an item prevents it from being changed
MyVar.IsProperty(ItemIs.Locked, true);

uc.EvalStr("x = 300"); // x cannot change here
Console.WriteLine(uc.EvalStr("x")); // x retains the previous value




				
			
100
200
200
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto MyVar = uc.DefineVariable("x = 100");
   cout << uc.EvalStr("x") << endl;

   uc.EvalStr("x = 200");
   cout << uc.EvalStr("x") << endl; // x can change here

   // Locking an item prevents it from being changed
   MyVar.IsProperty(ItemIs::Locked, true);

   uc.EvalStr("x = 300"); // x cannot change here
   cout << uc.EvalStr("x") << endl; // x retains the previous value




}
				
			
100
200
200
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim MyVar = uc.DefineVariable("x = 100")
      Console.WriteLine(uc.EvalStr("x"))
      
      uc.EvalStr("x = 200")
      Console.WriteLine(uc.EvalStr("x")) '// x can change here
      
      '// Locking an item prevents it from being changed
      MyVar.IsProperty(ItemIs.Locked, true)
      
      uc.EvalStr("x = 300") '// x cannot change here
      Console.WriteLine(uc.EvalStr("x")) '// x retains the previous value
      
      
      
      
   End Sub
End Module
				
			
100
200
200