- True values are the case-insensitive words yes, on, true, their unique abbrevations, and non-zero integers,
- False values are the case-insensitive words no, off, false, their unique abbrevations, and 0.
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 2007-01-18: 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
You can sometimes get into trouble relying on these different forms. For example, in Tk:
pack [checkbutton .cb -variable toggle] set toggle 1 ;# Works fine. set toggle true ;# Clears the checkbox!You can work around this using checkbutton's -onvalue and -offvalue arguments, but you're still limited to just one recognised value for each state:
pack [checkbutton .cb -variable toggle -onvalue true -offvalue false] set toggle true ;# Works fine. set toggle 1 ;# Clears the checkbox!
The canonical form for true, like in C, is integer 1. To wit:
% expr 42==42 1