File:  [Research Unix] / researchv10no / cmd / sml / doc / refman / equality.tex
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

\chapter{Equality}

The equality function \verb"op = : ''a * ''a -> bool" is available at
all types \verb"''a" except function types, abstract types, and the
types constructed from them.  In fact, type variables that begin
with two primes are special: they stand only for types that admit
equality.

Two values are tested for equality as follows, depending on the kind
of value:
\begin{description}
\item[Primitive types] like integers, reals, and strings have
equality functions with the conventional behavior.

\item[Function types] cannot be compared (``do not admit equality'').

\item[Reference types:] On references, equality means identity; a
reference is equal to itself and to no other references, regardless
of similar contents.

\item[Record types] may be compared if all their components admit equality.

\item[Datatypes] may be compared for equality if all of their
constructed types admit equality.

\item[Opaque types] from functor parameters and abstractions do not
admit equality unless the \verb"eqtype" keyword is used (instead of
the \verb"type" keyword) in the
signature defining them.
\end{description}

The function \verb"op <> : ''a * ''a -> bool" is the inequality function;
it is applicable to any equality type.

The comparison functions \verb">", verb"<", \verb"<=", and \verb">=" do not
have this behavior; they are overloaded just for the types
\verb"int", \verb"real", and \verb"string".

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.