September 04, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On 09/04/2015 04:41 PM, Andrej Mitrovic via Digitalmars-d wrote: > On 9/3/15, Andrei Alexandrescu via Digitalmars-d > <digitalmars-d@puremagic.com> 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 >> +=. > > The gist of it is that it's interesting because it's such a rare > occurrence. That's why we probably shouldn't even think about it. I've > never seen such mistakes in OSS code before, and I've never seen it in > production code either. It's so rare that we shouldn't spend any time > thinking about it. https://searchcode.com/codesearch/view/15360834/ was mentioned. > Sure it's interesting, but why bother with this special case when > there's bigger fish to fry? Most likely. My question was whether to put it in bugzilla or not. Guess not. Andrei |
September 05, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Friday, 4 September 2015 at 23:08:21 UTC, Andrei Alexandrescu wrote:
> On 09/04/2015 12:39 PM, skoppe 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 +=.
>>>
>>>
>>> Andrei
>>
>> Seems like a really, really small fish to catch. I wouldn't want to
>> litter my codebase with those kind of rules.
>
> I don't see what litter one would need you add to one's codebase?
>
I was speaking from the perspective of whoever maintains/wrote the tokenizer.
|
September 05, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mint | On Friday, 4 September 2015 at 18:55:03 UTC, Mint wrote:
> On Friday, 4 September 2015 at 17:17:26 UTC, Andrei
>
> A simple solution would be to just have unary + perform integer promotion, as it does in C.
Wait, what? Is this another secret difference from C integer promotion rules?
|
September 05, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to ponce | On Saturday, 5 September 2015 at 10:45:35 UTC, ponce wrote:
> On Friday, 4 September 2015 at 18:55:03 UTC, Mint wrote:
>> On Friday, 4 September 2015 at 17:17:26 UTC, Andrei
>>
>> A simple solution would be to just have unary + perform integer promotion, as it does in C.
>
> Wait, what? Is this another secret difference from C integer promotion rules?
To me knowledge, the unary '+' in D is essentially a no-op (much like it is in Java). Mimicking C promotion rules might help new programmers coming to D from C or C++ feel more familiar with the language. The caveat here would be that the unary '-' operator would need to also perform a similar promotion for consistency.
|
September 13, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | Am Fri, 04 Sep 2015 13:38:26 +0000 schrieb "Jonathan M Davis" <jmdavisProg@gmx.com>: > I didn't realize that a unary + operator existed. I would have assumed that +a as an expression would be illegal. It doesn't even mean anything. > > - Jonathan M Davis Often (mostly with linear algebra) you have e.g. a sum of 4 products that differ only in some index and the sign. I use to put superfluous + signs there and put each product on a separate line just to make the similarities stick out more. Sure they do nothing, but I'd miss them when there is ++/--/- as prefix operators but no +. About the proposal I'm undecided. Rare mistake, stuffing more fuzzy logic into the compiler front-end where I don't know how maintainable this is on the long run and how much in fact they start to annoy as they target mistakes that newcomers make, but may actually be legit. For example assuming you learned the operator precedence rules, warnings about adding parenthesis where the code was already correct can be annoying. "=+ " goes in the same direction. We could end up with DMD and SDC implementing a different set of somewhat fuzzy, well meant restrictions on what is correct code, that most of the time avoid errors and sometimes annoy. A compiler front-end is complex and such language patches may actually make the code less readable by adding snippets of code all over the front-end code bases. I like the "did you mean ..." messages though as the last step of symbol resolution. They happen when the code already doesn't compile and as such don't alter what is valid code and they have good visibility. So my opinion is to collect such snippets in a proper linter like https://github.com/Hackerpilot/Dscanner instead of burdening the front-end with them and creating a de-facto new DMD specific spec different from other emerging D implementations. -- Marco |
September 13, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Am Fri, 4 Sep 2015 19:13:45 -0400 schrieb Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org>: > Most likely. My question was whether to put it in bugzilla or not. Guess not. > > > Andrei Put it here: https://github.com/Hackerpilot/Dscanner/issues ;) -- Marco |
September 13, 2015 Re: Interesting user mistake | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 09/03/2015 06:46 PM, 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 +=. > > > Andrei https://github.com/D-Programming-Language/dmd/pull/5072 |
Copyright © 1999-2021 by the D Language Foundation