8 MyPrimitiveType

47* 13+   38  53
-------------------------------------------------------------------
----
---- ALLPROSE
---- Copyright (C) Ralf Hemmecke (ralf@hemmecke.de)
---- http://www.hemmecke.de/aldor
----
-------------------------------------------------------------------

#assert DontNeedLibraryMyAlps
#include "myalps"
cat: MyPrimitiveType 48

Uses DontNeedLibraryMyAlps 37.

Type Constructor

MyPrimitiveType

Usage

MyPrimitive: MyPrimitiveType == add {
  Rep == MachineInteger;
  (x: %) = (y: %): Boolean == rep x = rep y;
}

Description

The category of types that provide equality testing.

48cat: MyPrimitiveType 48  (47)
define MyPrimitiveType: Category == with {
        exports: MyPrimitiveType 49
    default {
        defaults: MyPrimitiveType 50b
    }
}

Defines:
MyPrimitiveType, used in chunk 61.

Exports of MyPrimitiveType

=: (%, %) -> Boolean Tests equality.

~=: (%, %) -> Boolean Tests inequality.

Export of MyPrimitiveType

=: (%, %) -> Boolean

Usage

if x = y then ...

Parameters

x: %

y: %

Elements to be tested.

Description

Tests equality.

If x = y is true, then x and y are equal elements of the type. It does not (necessarily) mean that the elements are identical in the sense that they represent the same location in memory.

If x = y returns false means that equality cannot (computationally) be confirmed, i. e., whether x is really different from y depends on the type. For types that do not allow for full equality tests (as, for example, sequences) it should be interpreted as: x and y do not represent the same memory location and equality cannot be confirmed computationally.

The semantics of x ~= y is the boolean negation of x = y.

49exports: MyPrimitiveType 49  (48)  50a
=: (%, %) -> Boolean;

Export of MyPrimitiveType

~=: (%, %) -> Boolean

Usage

if x ~= y then ...

Parameters

x: %

y: %

Elements to be tested.

Description

Tests inequality.

The semantics of x ~= y is the boolean negation of x = y.

50aexports: MyPrimitiveType 49+   (48)  49
~=: (%, %) -> Boolean;

A domain that implements the category MyPrimitiveType need not explicitly implement inequality testing since the category already provides the following default implementation that should only be overridden if there is a faster way in a specific domain to test for inequality.

50bdefaults: MyPrimitiveType 50b  (48)
(x: %) ~= (y: %): Boolean == ~(x = y);