is (leftValue rightValue -- isIdentityLike)
Inputs
leftValue: First operand.rightValue: Second operand.
Outputs
isIdentityLike:Condresult that isTRUEwhen the identity-like comparison holds, and unknown when that comparison cannot be decided at compile time.
is requires matching dereferenced schemas, then applies the identity-like rules below. Ref operands are compared by target identity, not by the values stored in their targets.
All same-schema inputs are accepted. Identity-like equality is meaningful for Ref, Text, and Code objects. Other same-schema inputs return FALSE.
is answers a different question from = and same. Use = for equality of values after dereferencing and same for dereferenced schema identity.
Behavior
- The dereferenced schemas of both inputs must match. If they do not, the call is invalid; it does not return
FALSE. - Matching schema is not enough by itself. For In-place objects, the builtin returns
FALSEeven whensameand=would both returnTRUE. - For Ref objects, known Ref objects compare by target identity, so two Ref objects to different equal-valued targets still give
FALSE. - For Text, known Text objects compare by their contents.
- For Code, two known
NILvalues giveTRUE. Known non-NILCode objects giveFALSE. Unknown Code objects produce an unknown Cond result. - If supported objects have unknown values, the builtin produces an unknown Cond result with a runtime equality check instead of a known
TRUEorFALSE.
Example
{} 0 {} [
nilCode: {} () {} codeRef;
compiledCode: {} () {} codeRef;
[] !compiledCode # a non-NIL Code
first: 7;
second: 7;
textA: 0 ("") dynamic @; # an unknown Text
textB: 0 ("") dynamic @;
"-- In-place values --" printCompilerMessage
7 7 same printStack _:;
7 7 = printStack _:;
7 7 is printStack _:;
"-- Ref values compare target identity --" printCompilerMessage
@first @first is printStack _:;
@first @second is printStack _:;
"-- text compares contents --" printCompilerMessage
"hi" "hi" is printStack _:;
"hi" "ho" is printStack _:;
"-- unknown supported values can produce unknown Cond --" printCompilerMessage
textA textB is printStack _:;
"-- code --" printCompilerMessage
@nilCode @nilCode is printStack _:;
@compiledCode @compiledCode is printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- In-place values --
TRUE
TRUE
FALSE
-- Ref values compare target identity --
TRUE
FALSE
-- text compares contents --
TRUE
FALSE
-- unknown supported values can produce unknown Cond --
Cond
-- code --
TRUE
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 -- isEqual)Tests equality of values after dereferencing for Cond, numeric, and Text objects of the same schema.>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.samebuiltin(leftSchema rightSchema -- isSameSchema)Tests whether two dereferenced schemas are exactly the same; this is schema equality only, not runtime-value equality.