Improving Compiler Error Messages

Nick Sabalausky a at a.a
Mon May 3 11:29:23 PDT 2010

"Walter Bright" <newshound1 at> wrote in message 
news:hrn1vj$ild$1 at
> bearophile wrote:
>> It's hard to answer similar questions in an objective way.
>> In Python 2.x the line continuation is implicit if you are inside a 
>> parenthesis:
>> print (x +
>>  5)
> The trouble with that, from a language perspective, is what does the 
> grammar look like? Since the newline is significant to parsing, it should 
> be a token. But inside ( ), there's a problem with it being a token, 
> because now the grammar is messed up by needing to accept an optional 
> newline token in between any other two tokens - but only if inside ( ).
> The obvious technical solution is to turn off recognition of newline 
> tokens inside of ( ). This is characterized as "smart" parsing, but I have 
> a less kind word for it - "hack" - because it means there's not a clean 
> way to separate the lexer from the parser, and not a clean way to express 
> the grammar.
> From a language user's perspective this probably doesn't matter, but these 
> kinds of things have a way of biting back in unanticipated nasty ways in 
> the future. For example, C++'s use of < > for templates is a similar hack 
> in the grammar. The C++ committee was warned at the time it was a very bad 
> idea that would cause all kinds of problems, but they went ahead anyway 
> because they thought it wouldn't affect users.
> Turns out it did affect them, and it has caused a lot of grief over the 
> years. There's another hack in C++0x in an attempt to paper over the 
> problem.

Standard C++ design seems to be to paper over problems. That's probably the 
#1 reason I moved to D years ago.

More information about the Digitalmars-d mailing list