3.3. kink/BOOL

Companion mod for bool vals.

3.3.1. type bool

Bool vals are true or false, which are the results of CORE.true and CORE.false respectively.

See CORE.if for 1-way or 2-way branch.

For multi-way branch, use CORE.branch fun.

See CORE.op_lognot, CORE.op_logor, and CORE.op_logand for logical operations. They are translated from !, ||, and && operators. Example:

# whether S has a whitespace character on the head or the tail
:strippable? <- {(:S)
  ! S.empty? && (S.get(0) == 0x20 || S.get(S.size - 1) == 0x20)

stdout.print_line(strippable?('foo').repr)  # => false
stdout.print_line(strippable?(' foo').repr) # => true
stdout.print_line(strippable?('foo ').repr) # => true
stdout.print_line(strippable?('').repr)     # => false


Bool.op_eq returns whether two bool vals are equal.

Arg_bl must be a bool.

If both Bool and Arg_bl are true, or both Bool and Arg_bl are false, Bool.op_eq returns true.

If Bool is true and Arg_bl is false, or Bool is false and Arg_bl is true, Bool.op_eq returns false.

Note that an expression “X == Y” is translated to “(X).op_eq(Y)”. See Semantics section of the manual.


Bool.repr returns "true" for true, "false" for false.

3.3.2. BOOL.is?(Val)

BOOL.is? returns whether the Val is a bool val.


stdout.print_line(BOOL.is?(true).repr)   # => true
stdout.print_line(BOOL.is?(false).repr)  # => true
stdout.print_line(BOOL.is?(42).repr)     # => false