Sidharth Pallai wrote:If we could be able to answere "Why an IF construct accepts only boolean / booleanic results" . . .
How on earth could an "if-then-else" accept anything other than a Boolean value as its test?
I think that might have been referring to other languages which accept innovative things like 0 and 1 as the conditions for if-statements. In other words there are rules in the language which coerce integer values (or possibly other junk for all I know) to boolean values. For example XSLT allows you to use a node-set as a condition for the xsl:if element by coercing empty sets to false and non-empty sets to true.
posted 10 years ago
Yes, of course. In fact the theoretical basis for an if-then-else only takes boolean values for its test, but most production languages cheat by using 0 for false and non-zero (1, -1, etc)for true.