6 ms·
Interesting to see they are removing some of the quirkier things... - Remove Trigraphs. - Remove K&R function definitions/declarations (with no information ab
by keithnz 3y ago
Interesting to see they are removing some of the quirkier things...
- Remove Trigraphs.
- Remove K&R function definitions/declarations (with no information about the function arguments)
- TwentyPosts 3y agoWait, 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...
- fuzztester 3y ago>Remove K&R function definitions/declarations (with no information about the function arguments) Not used C for many years, but used it a lot earlier. And had read both the first and second editions of the k&r c book (ed. 1 pre-ansi, ed. 2 ansi). based on that, iirc, this: >Remove K&R function definitions / declarations should actually be: function definitions / declarations as in the first edition of the k&R C book.
- trealira 3y agoThe second edition of K&R distinguishes between them by calling the pre-ANSI declarations old-style functions, and the ANSI declarations new-style functions. Although, since it's not 1989 anymore, they're not exactly new to C either. ANSI C has been around for 35 years at this point, whereas in 1989, C was only 17 years old.
- fuzztester 3y agoYes, I knew that, though I did not mention it. In my previous comment, I was going to say (from memory), that in the second edition, i.e. in ANSI C, both types of declarations are allowed, old style and new style. Also, if you just wrote the declaration (return value, then function name followed by types with arguments in parentheses), followed by a semicolon, without a function body in braces, it was called a function prototype. MS C (as in, some version of Visual Studio's command line C compiler), had a flag to generate the prototypes from the function definitions. I had used it some. /Zg, possibly.
- trealira 3y agoSorry, I wasn't trying to imply that you didn't know that. I meant to suggest that it would be the most unambiguous way to differentiate them, but then realized that the names weren't accurate because C89 declarations aren't new anymore. So, I shouldn't have written the comment anyway.
- fuzztester 3y ago
- casey2 3y agoWhat do you mean about the second one? In K&R functions are explained as name (argument list, if any) argument declarations, if any { declarations statements } Is this disallowed in C23?
- lifthrasiir 3y agoYes. And `int name() { ... }` now is same to `int name(void) { ... }`.