Go to the first, previous, next, last section, table of contents.


11.1.5 int Trait

The trait int is somewhat different from others in that it also defines conversion functions between int and Bool. The trait functions to_int and to_bool respectively convert Bool values to sort int and int values to sort Bool. (The sorts Bool and bool are synonyms. The sort int is not a synonym of the LSL sort Int, because they have different properties.) As in C++, 0 is treated as false and all non zero values are regarded as true.

% @(#) $Id: int.lsl,v 1.11 1995/11/09 21:22:39 leavens Exp $
int(int): trait
  includes short(int, INT_MIN for SHRT_MIN, INT_MAX for SHRT_MAX)
  introduces
    to_bool, to_LSL_Bool: int -> Bool
    to_int: Bool -> int
  asserts
    \forall i: int
      to_int(false) == 0;
      ~(to_int(true) = 0);
      to_bool(i) == ~(i = 0);
      to_LSL_Bool(i) == to_bool(i);


Go to the first, previous, next, last section, table of contents.