Hacker News new | ask | show | jobs
by 1amzave 3766 days 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.
3 comments

Another 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?
Good 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.
Early 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.

By itself it's almost certainly a function call with a discarded return. The result is not assigned to anything.