Comparison of arrays, objects and code blocks in variables

I Love Xbase++ (ILX)
The portal for Xbase++ developers worldwide

Pat France

New member
Staff member
I am here to help you!
Aug 9, 2022
23
3
3
Customer Identifier
E114627
Variables containing arrays, objects and code blocks contain a reference to the variable's value, and not the actual value itself. This means that two object variables may point to the same object, whereas two numeric variables always store two separate values - even though their numeric value may happen to be the same. This fact introduces some interesting peculiarities which developers need to be aware of.

Examples:
Xbase++:
// Same numeric value
n1 := 12
? n1 == 12         // Result: .T.

// Same array reference
a1 := {}
a2 := a1
? a1 == a2         // Result: .T.

// Not the same array reference
a1 := {}
? a1 == {}         // Result: .F.

// Same code block reference
b1 := {|| NIL}
b2 := b1
? b1 == b2         // Result: .T.

// Not the same code block reference
b1 := {|| NIL}
? b1 == {|| NIL}   // Result: .F.

// Same object reference if oMyDialog is a child of the desktop object
o1 := AppDesktop()
o2 := oMyDialog:setParent()
? o1 == o2         // Result: .T.

This means that when comparing objects, arrays and code blocks, care must be taken to distinguish between a variable's value and the instance/object it references.

For further information about comparing values of complex data types, see the following sections in the documentation:
 
Last edited by a moderator: