5 ms·
While this is a legitimate complaint, it also applies (though in fewer ways) to C. How do you parse this? (x)(y); Is that a call of function (or function p
by 1amzave 11y ago
While this is a legitimate complaint, it also applies (though in fewer ways) to C. How do you parse this?
(x)(y);
Is that a call of function (or function pointer) `x` with argument `y`? Or is it a cast of `y` to type `x`? You need to have kept track of of all the typedefs in the code prior to that point to know.
- beat 11y agoGood point. But keep in mind that C predates C++ by over 15 years. There were tremendous advances in theory in that time. It's not completely fair to compare a hacker's tool from 1970 with a state of the art academic exercise from 1987.
- unscaled 11y agoEarly versions of C date to 1972, while early versions of C++ (called C with classes back then) date 1979, only 7 years later, probably a few rooms down the hall from where C was originally developed. True, templates came much later, but by then C++ was already hopelessly unparsable by LALR(1) parsers. But in truth, it was this way from moment 0, since it was based on C-syntax. Making it parsable by yacc was a lost cause, since yacc followed C and not the other way around.
- koenigdavidmj 11y agoAnother one: x * y; Is that a multiplication, whose result is being thrown away, or a declaration of a variable y of type pointer-to-x?
- ArkyBeagle 11y agoBy itself it's almost certainly a function call with a discarded return. The result is not assigned to anything.