The problem is that the English words "true" and "false" are adjectives, not nouns: the semantics of a comparison are that you are taking one thing and comparing it to another thing, but "true" isn't a thing, it's a description of a thing. (This is why an expression like "if (true == a)" looks backwards, despite being perfectly legal.)
Boolean keywords should be named "truth" and "falsehood" to more accurately convey their usage.
2 comments:
Does "if (truth == a)" or "if (a == truth)" really look any better?
I think the real problem here is the equivalency indicator. a does not *equal* true, it just has the *property of being* true. Or it is a *subset of* the truth.
So we could have true(a) and false(a). Or maybe a.truthValue. Or memberOf(truth, a).
Yeah, I was just trying to fix comparisons to be grammatically correct in English terms, but actually allowing you to use adjectives would be a cool language feature.
C# has an "is" operator used for recognizing types ("if (obj is IStream)") which could serve as a model from a syntax standpoint.
Post a Comment