Advanced Computing Environment
Hosted by SourceForge
brix-os project page

Previous: Enumerations ----- Up: Contents ----- Next: Collections


Boolean inherits from Enum and exports two constants representing the true and false states. All conditional extensions require Boolean values or relational expressions resulting in Boolean values. This improves readability by forcing if(value > 0) instead of if(value).

	someflag := true
	if a==b and a>0 and someflag==true, echo "foo";






NOTtrue when false
ANDtrue when both trueshort-circuits to false - on false
ORtrue when one or both trueshort-circuits to true - on true
XORtrue when one false and one true
NANDtrue when one falseshort-circuits to true - on false
NORtrue when both falseshort-circuits to false - on true

Sample Definition

	// declare without relational_interface ~
	`export-root Boolean = deftype () {
	  inherit (Enum(~ false true), equality_interface)
	  logical_not  = def (a:Self) -> Self ...
	  logical_and  = def (a:Self, b:Self) -> Self ...
	  logical_or   = def (a:Self, b:Self) -> Self ...
	  logical_xor  = def (a:Self, b:Self) -> Self ...
	  logical_nand = def (a:Self, b:Self) -> Self ...
	  logical_nor  = def (a:Self, b:Self) -> Self ...
	  isEqual      = def (a:Self, b:Self) -> Self ...

	// operators
	defop`prefix not (right:Boolean) -> Boolean.logical_not(right)
	defop`infix and (left:Boolean, right:Boolean) -> Boolean.logical_and(left, right)
	defop`infix or (left:Boolean, right:Boolean) -> Boolean.logical_or(left, right)
	defop`infix xor (left:Boolean, right:Boolean) -> Boolean.logical_xor(left, right)
	defop`infix nand (left:Boolean, right:Boolean) -> Boolean.logical_and(left, right)
	defop`infix nor (left:Boolean, right:Boolean) -> Boolean.logical_and(left, right)

	// true/false constants
	`export-root false:Boolean = `false;
	`export-root true:Boolean = `true;

Previous: Enumerations ----- Up: Contents ----- Next: Collections