On Friday, September 28, 2012 04:12:46 Andrej Mitrovic wrote: > This is a very specific situation that could be handled unless it is > too complex to mess with the lexer. If there's an if statement which > isn't followed by a block but is followed by a blank line emit a > warning. Sounds simple enough to me.
But the lexer explicitly throws away all whitespace. Like pretty much every other C-based language, D doesn't care about whitespace, and the lexing process only uses it to separate tokens. Beyond that, it's gone from the whole compilation process. And you don't know what an if statement is until you've completed the parsing process which is _after_ the lexing. The way a compiler is typically built, it just doesn't have the capability to warn you about formatting. The language is specifically designed to _ignore_ it. As easy as it may be for you to see the whitespace and consider it bad, the way the compiler looks at things just doesn't lend itself to figuring this sort of thing out. So, yes, it would be a royal pain to warn about this sort of thing even if it's unequivocally bad code. - Jonathan M Davis