Joseph Coveney that's a great point. You can really see the C/C++ influences in Stata's language design in your description. In fact, much like Stata, C doesn't have a boolean type. C does have a few exceptions to the rule that:
Some nonzero values (e.g. the null pointer) are treated as false in C, but all in all, very similar.
I felt like it was easier to know where things stand in a ternary logic system like in R. It is surprisingly intuitive and It leads to some very elegant code. It just felt natural. There were a lot of things about R that I did not like: (<- for assignment? seriously? I have to hit three keys now?), but the ternary logic is one place where R really shines. Then I started to learn ado, and wow is the syntax intuitive and easy to understand quickly. On the other hand, I was disappointed when I learned that the syntax leads to some regrettable beginner errors regarding missing numbers, whereas R seemed to handle all of these problems behind the scenes.
I admit, it is possible I just prefer what is familiar to me, but I do think R does this particular thing better, and its because of the ternary logic system.
0 is False. Everything else (everything else) is True.
You might not like that, but at least it's easy to know where things stand, and that's an important consideration in control flow.
I admit, it is possible I just prefer what is familiar to me, but I do think R does this particular thing better, and its because of the ternary logic system.
Code:
> d <- 1:10 > d[3] = NA > d > 5 [1] FALSE FALSE NA FALSE FALSE TRUE TRUE TRUE TRUE TRUE
Comment