= (leftValue rightValue -- isEqual)
Inputs
leftValue: Left operand in the comparison.rightValue: Right operand in the comparison.
Outputs
isEqual:Condresult that isTRUEwhen the dereferenced objects are equal, and unknown when equality cannot be decided at compile time.
= compares dereferenced objects by value equality.
Supported inputs are values whose dereferenced schemas are same-schema Cond, numeric, or non-NIL Text.
= answers a different question from is and same. Use is for identity-like equality and same for dereferenced schema identity.
Behavior
- If the dereferenced schemas differ, the builtin is invalid. It does not return
FALSE. - Ref objects are dereferenced before comparison. Different Ref objects to equal-valued targets therefore make
=returnTRUEeven whenisreturnsFALSE. - Known Text objects compare by their UTF-8 contents.
- If both dereferenced objects are known, the result is known at compile time.
- If either dereferenced object is unknown, the result is an unknown Cond.
- A known
NILText input is invalid.
Known issue: when either Text operand is unknown, = compares only data pointers and ignores byte lengths and contents; keep Text values known before using = for content equality. For run-time Text, compare String views instead: apply makeStringView to both operands, then use =.
Example
{} 0 {} [
condValue: TRUE dynamic;
first: 7;
second: 7;
numberValue: 0 dynamic;
textValue: 0 ("") dynamic @; # an unknown Text
"-- cond --" printCompilerMessage
TRUE TRUE = printStack _:;
TRUE FALSE = printStack _:;
condValue TRUE = printStack _:;
"-- numbers compare by value --" printCompilerMessage
7 7 = printStack _:;
7 8 = printStack _:;
"-- references are dereferenced first --" printCompilerMessage
@first @second = printStack _:;
@first @second is printStack _:;
"-- unknown int32 --" printCompilerMessage
numberValue 7 = printStack _:;
"-- text --" printCompilerMessage
"alpha" "alpha" = printStack _:;
"alpha" "beta" = printStack _:;
"-- unknown text --" printCompilerMessage
textValue "alpha" = printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- cond --
TRUE
FALSE
Cond
-- numbers compare by value --
TRUE
FALSE
-- references are dereferenced first --
TRUE
FALSE
-- unknown int32 --
Cond
-- text --
TRUE
FALSE
-- unknown text --
Cond
See also
<builtin(leftValue rightValue -- isLess)Tests whether the left dereferenced object is less than the right one for supported same-schema numeric or known Text objects.>builtin(leftValue rightValue -- isGreater)Tests whether the left dereferenced object is greater than the right one for supported same-schema numeric or known Text objects.isbuiltin(leftValue rightValue -- isIdentityLike)Tests identity-like equality for references, Text, and Code objects of the same dereferenced schema; In-place objects of the same schema still giveFALSE.samebuiltin(leftSchema rightSchema -- isSameSchema)Tests whether two dereferenced schemas are exactly the same; this is schema equality only, not runtime-value equality.