6 ms·
Wait, no trigraphs anymore??? This is horrible, I loved using `and` and `not` and `or` in C boolean expressions and to pretend I'm writing Python code. It's fu
by TwentyPosts 3y ago
Wait, no trigraphs anymore???
This is horrible, I loved using `and` and `not` and `or` in C boolean expressions and to pretend I'm writing Python code. It's fun!
- bombela 3y agoI find those keywords much more readable, and faster to type (qwerty). I also wish Rust had those instead of the weird symbols. Oh well, c'est la vie.
- pitaj 3y agoIn Rust you can just use the method call `expr.not()`
- pzmarzly 3y agoWhile it's true that in Rust most operators (eg. all arithmetic operators, as well as !, &, |, ^) are just syntax sugar over some trait methods that you could call directly, this is not the case for boolean "and" and "or": && and || have to be special due to their short-circuiting properties (in "false && b()" b never gets called, same in "true || b()").
- agapon 3y agoThose are not trigraphs, of course.
- TwentyPosts 3y agoReally? The Wikipedia article on trigraphs seems to disagree. Why do you think so?
- iainmerrick 3y agoLooks like that article is a general one on two- and three-character sequences. In C, "trigraph" specifically refers to nine special sequences beginning with "??": https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C They were used to provide an alternate way of typing punctuation characters for keyboards that don't have them (e.g. "??(" is "[").
- trealira 3y agoThose aren't trigraphs; those are macros defined in the <iso646.h> header, like this: #define and && #define not ! /* ... and so on */ In C++, they're actually keywords that are built into the language, so you don't need a header then. When people talk about trigraphs in C, they're talking about the trigraphs listed on this page: https://en.cppreference.com/w/c/language/operator_alternative https://en.cppreference.com/w/c/language/operator_alternativ...