Version 10 of true

Updated 2007-01-18 15:17:15 by AM

True is a boolean value. It is recognised by expr.

  1. True values are yes, on, true, their unique abbrevations, and non-zero integers,
  2. False values are no, off, false, their unique abbrevations, and the integer 0.

The function string is true returns true if its argument obeys the condition 1. above (and string is false does the opposite).

Unless the -strict flag is passed both [string is true ""] and [string is false ""] (i.e., testing the empty string) return 1. This is the case to facilitate entry validation in Tk.


LV I guess I must be really too old for programming languages, because making a command return a wrong answer to facilitate some other action, in AN EXTENSION, seems just wrong to me.

AM (18 january 2007) If it is any consolation, in mathematics one needs to deal with similar special cases:

  • The sum over zero elements
  • The product over zero elements
  • Quantifiers over the empty set
  • In geometry one usually deals with objects "in general position" to avoid thinking about a bunch of collinear points for instance

It may seem to be a bizarre hack to make some long forgotten program work, and it probably is. But taking care of these nauseating edge cases is a part of life.


The canonical form for true, like in C, is integer 1. To wit:

 % expr 42==42
 1

1S See also: Boolean, magic names


Category Glossary Category Internals