Operators: ^

XOR operator.

Syntax

Binary form:

integer‑operand^integer‑operand

styles‑operand^styles‑operand

user‑defined‑set‑operand^user‑defined‑set‑operand

Unary form:

property‑reference‑operand^

^property

^data‑type

Bitwise XOR

In its first version, the ^ operator performs on the both operands a bitwise exclusive OR operation. If used in combination with 8-, 16- or 32-bit signed integer operands, the data type resulting from the operation is consequently int32. When mixing signed and unsigned integer operands, the operation results in the unsigned uint32 value. In the case, one of the operands is 64-bit large, the resulting data type is int64 or uint64 according to whether the 64-bit operand is signed or unsigned. For example:

var uint32 a = 0xFF003AC0; var uint32 b = 0xAB15FF70; var int32 c = 1369; // = 0x00000559 var int32 d = -1496; // = 0xFFFFFA28 var uint64 e = 0x1234AB15FF70; var int64 f = -149613691251; // = 0xFFFFFFDD2A543E8D var uint32 result = a ^ b; // result = 0x5415C5B0 var int32 result = c ^ d; // result = -143 var uint32 result = a ^ d; // result = 0x00FFC0E8 var int64 result = a ^ f; // result = 0xFFFFFFDDD554044D var uint64 result = d ^ e; // result = 0xFFFFEDCB54EA0558

Styles exclusive disjunction

In its second version, the ^ operator combines the both styles operands to a new styles value. Please note, styles operands can be considered as collections containing multiple elements you can individually include or exclude. Thus, the ^ operation results in a new styles value including only those elements which exist either in the left OR in the right operand but not in the both. The resulting data type of the operation is always styles. For example:

var styles a = [ Style1, Style3, Style16 ]; var styles b = [ Style3, Style16 ]; var styles c = [ Style1, Style8 ]; var styles result = a ^ b; // result = [ Style1 ] var styles result = b ^ c; // result = [ Style1, Style3, Style8, Style16 ]

Set exclusive disjunction

In its third version, the ^ operator combines the both user-defined set operands to a new set value. Please note, set operands can be considered as collections containing multiple elements you can individually include or exclude. Thus, the ^ operation results in a new set value including only those elements which exist either in the left OR in the right operand but not in the both. The resulting data type of the operation corresponds to the data type of the operands. For example:

var Core::Layout a = Core::Layout[ AlignToTop, ResizeHorz ]; var Core::Layout b = Core::Layout[ ResizeHorz ]; var Core::Layout c = Core::Layout[ AlignToTop, ResizeVert ]; var Core::Layout result = a ^ b; // result = Core::Layout[ AlignToTop ] var Core::Layout result = b ^ c; // result = Core::Layout[ AlignToTop, ResizeVert, ResizeHorz ]

Indirection operator

In its fourth version, the ^ operator is used to access the value of the property represented by the property reference operand. Dereferencing a property reference causes the properties own onget or onset methods to be called depending on whether the property is involved in an expression or a new value is assigned to the property. For example:

var ^int32 a = ... // Some reference to an int32 property // Read the value of the referenced property (onget method is called) var int32 result = a^; // Modify the referenced property (onset method is called) a^ = 1369;

Reference operator

In its fifth version, the ^ operator returns a reference to the property specified in its operand. Later, the reference can be used to read and modify the property without needing to know anything about the object, this property belongs to. For example:

var ^rect result = ^SomeTextView.Bounds; // result = reference to the property 'Bounds' [...] // Later access the property using the indirection operator result^ = <100,200,110,220>;

Reference data type operator

The sixth version of the ^ operator is used exclusively in declarations of data members to indicate, that the affected data member is intended to store a reference to a property instead of the data value itself. The data type specified in the operand has to match the type of the property you intend to store in the member. For example:

// Declare a local variable able to store references to properties of the data type 'string' var ^string refToStringProperty; // Store a reference to a string property refToStringProperty = ^SomeTextView.String; [...] // Later access the property using the indirection operator refToStringProperty^ = "Hello World!";