3 ms·
The most vexing parse is not an issue in "C and C++ grammars", it is only an issue in C++ which has really stupid initialization syntax that looks like a functi
by bruce343434 4y ago
The most vexing parse is not an issue in "C and C++ grammars", it is only an issue in C++ which has really stupid initialization syntax that looks like a function call.
C and C++ are not the same language nor even that similar. It's a shame they are always mentioned together under the same breath.
- woodruffw 4y agoAuthor here: the examples in the blog post are for C++, but a variant of the MVP also occurs in C when uniform declaration interacts with typedefs. Here's an old (1992!) comp.compilers post on it[1]. [1]: https://pdos.csail.mit.edu/archive/l/c/roskind.html https://pdos.csail.mit.edu/archive/l/c/roskind.html
- planede 4y agoI would say that these are context-sensitive, but it doesn't seem to be analogue to C++'s most vexing parse. In the most vexing parse case all identifiers are resolved to the correct kind (type name or variable name), yet it is still ambiguous. The C examples are unambiguous after the kind of the identifiers are identified. A C exmaple: T(*ptr)[42]; If T is a type then this is a declarations of a pointer to an array of T. If T is a function, then this is a function call followed by a subscript (which is then discarded). A similar C++ analogue would be: C<0>(0); If C is a function template with a non-type template parameter, then this is a function call of C<0> with argument 0. If C is an int variable instead then it is equivalent to the following expression (C < 0) > 0 . But for T a(); in both possible interpretations T is a type, and 'a' is the new entity being declared. So parsing this is not context-sensitive, it's simply ambiguous. C++ resolves the ambiguity by choosing in favor of function declarations. I'm not aware of a C analogue similar to this.
- woodruffw 4y agoTo be clear: I'm not claiming they're analogous, only that they're both consequences of uniform declaration and are historically grouped together when talking about "vexing parses."
- pdmccormick 4y agoIf I ever see a resume or a job description that lists "C/C++", that's a red flag to me that either someone might not actually have that much experience, or someone doesn't actually know what they are looking for.
- woodruffw 4y agoIME, people who list "C/C++" on their resumes tend to be recent undergraduates. When asked about it, they usually have C experience from one or two systems courses, and C++ experience from a separate course. Undergraduate courses tend to teach C++ as an "extension" of C because it eliminates the hump (and anxiety) of teaching an entirely new language, at the cost of being technically misleading.
- pjmlp 4y agoYou will find plenty of those from the job boards of the companies that seat at ISO C++, and their SDK documentation. Once upon a time, "The C/C++ Users' Journal" was the reference magazine for C and C++ developers. As per English grammar rules, / is an abbreviation, https://eslgrammar.org/forward-slash/ https://eslgrammar.org/forward-slash/