Mixin Boolean

Introduction

This mixin adds the Boolean operators to a class, so that wherever your class is one or more of the operands in a boolean test, its truth value can be evaluated consistently. Boolean operations include:

TestOperatorsExamples
Truthif (myobj)
Falsehood!, .not.if (!myobj)
And&&, .and.if (myobj && other)
if (other && myobj)
Or (inclusive)||, .or.if (myobj || other)
if (other || myobj)
Or (exclusive).xor.if (myobj .xor. other)
if (other .xor. myobj)

Usage

To use this mixin, you must define the identifier BOOLEAN_CLASS as the class under compilation and then include the module. For example:


class myclass
.define BOOLEAN_CLASS, myclass
.include "MIXINS:Boolean"

method truth, boolean
proc
    ;Return true if we're true.
end

You must supply the instance method "truth" shown above, which may be public, private, or protected. This method will be invoked whenever one of the Boolean operations shown above needs to test your object.

The Boolean mixin creates versions of the binary operators when your class is one of the operators and the other operator is integer (includes boolean), decimal, alpha (includes string), or another instance of your class. It does not handle the case of another class that provides its own Boolean operators.