<< Prev | - Up - | Next >> |
The equality test ==
checks whether two Oz values are equal. It is a function of type
. For instance, a record without subrecords is identified with its label.
{Inspect atom==atom()}
{Inspect {IsRecord atom}}
{Inspect {And true==true()
{And unit==unit()
false==false()}}}
{Inspect "hiho"==[104 105 104 111]}
The function ==
for testing equality can be used to built expressions. Note the ==
is very much different from the operator =
in assigment statements. The latter operator =
binds a variable (usually on the left) to a value (usually on the right). The former equality test ==
returns a Boolean value, but only if both input arguments are known. Otherwise, it waits until they become known. The programmer must be careful because all followup up commmands are suspended too.
%% introduce a free variable
declare X
%% the equality test waits until the value of X is known.
%% the following browse statement therefore waits too.
{Browse X==2}
%% feed the next line independently.
X=3
%% now the Browser should browse false
The equality test proceeds only once X
gets bound to its value. The Browse
can only become active once this has happened.
The above example may go wrong if you feed the above lines in a single block, since everything in the same block that succedes a blocking statement blocks. The statement that assign a value to X
must thus be fed in another block.
<< Prev | - Up - | Next >> |