Interesting user mistake

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 3 10:08:44 PDT 2015


On Thu, Sep 03, 2015 at 12:46:29PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> http://stackoverflow.com/questions/32369114/leap-years-not-working-in-date-and-time-program-in-dlang
> 
> The gist of it is the user wrote =+ instead of +=. I wonder if we
> should disallow during tokenization the sequence "=", "+", whitespace.
> Surely it's not a formatting anyone would aim for, but instead a
> misspelling of +=.
[...]

Is there a way for the lexer to check for the specific character
sequence '=', '+', whitespace and not others (e.g. '=', whitespace,
'+')?  IOW, "a =+ b" will be prohibited, but "a = + b" will be allowed.
If so, I agree with this.

On that note, though, the unary + operator is totally useless in D...
maybe we should get rid of that instead?  (Then "=+" will automatically
be an error.)


T

-- 
If it's green, it's biology, If it stinks, it's chemistry, If it has numbers it's math, If it doesn't work, it's technology.


More information about the Digitalmars-d mailing list