Interesting user mistake

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 4 08:13:08 PDT 2015


On 9/4/15 10:05 AM, Jonathan M Davis wrote:
> On Friday, 4 September 2015 at 13:55:03 UTC, Jonathan M Davis wrote:
>> On Thursday, 3 September 2015 at 16:46:30 UTC, Andrei Alexandrescu 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 +=.
> [snip]
>
> Actually, I may have misunderstood the suggestion. I do _not_ think that
> we should require that someone who writes code like
>
> a=+b;
>
> should be forced to put whitespace in their code, as ugly as it arguably
> is that they don't (which is what I thought was being suggested).
> However, if they've written their code like
>
> a =+ b;
>
> then it would make sense to warn about it, since the odds of that being
> legitimate are nearly zero, and the same goes for any other unary
> operator.

I think that is Andrei's original suggestion:

the sequence "=", "+", whitespace should be rejected.

He says nothing about "=","+" without the whitespace.

-Steve



More information about the Digitalmars-d mailing list