Statements in most languages can be empty

2 August, 2009 (19:31) | Programming

I was looking through some code that was posted for review when someone had pointed out a statement like the following:

int x=5;;

Note the two semi-colons. I initially thought “Great, someone has us reviewing code they didn’t even try to compile.” But to my amazement, it does compile, and it compiles in pretty much every language. I’ve tested it on the newest and oldest stuff I have, the oldest/obscurest thing I could come up with was Borland Turbo Pascal 7 (the EXE has a date of 10/30/1992). I’m sure there’s some deep theoretic reason parsers need to accept it, but to a human, it looks like an obvious error.

Write a comment