Operator Precedence/Boolean Logic
Lawrence D’Oliveiro
lawrencedo99 at gmail.com
Sun Jul 17 03:44:40 EDT 2016
On Sunday, July 17, 2016 at 7:33:19 PM UTC+12, Chris Angelico wrote:
> 1) REXX and, I think, Pascal: there are two specific values that may
> be used in conditionals, and anything else is an error
Worth comparing how two different languages deal with strict enforcement of booleans:
* Modula-2 does it right: BOOL is a separate type which is required for conditionals, but
+ the ORD and VAL functions offer typesafe conversions to and from integers, and
+ BOOL can be used as an array index type, just like any other enumerated type.
* Java does it wrong: not only does it not provide easy conversions, but it doesn’t allow enumerations to be used as array index types.
Python would do well to learn from the Modula-2 style.
More information about the Python-list
mailing list