March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu: > And by the way the irony here is that you seem to ignore my argument. Yes, sorry, politics is not for me. Better to go back discussing technical matters. >Some examples of what you're trying to achieve would be great,< Tuples are simple entities, so in past threads I have given examples of all my usages cases. If you want I can copy them again here (usage examples don't ask for a specific syntax, they are just about the desired semantics). >with the understanding that you're looking at at least five years until we'd be able to change anything about the use of comma.< C code should not silently behave differently in D, even five years from now, so I am not interested in using the C comma syntax for D tuples. I am OK with a D tuple syntax that is not allowed in C. I want to remove comma operators from D to avoid bugs and to make D code more readable. For me those are very important things, more important than the little code breaking it causes. Bye, bearophile |
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | "Kenji Hara" <k.hara.pg@gmail.com> wrote in message news:mailman.27.1395624482.25518.digitalmars-d@puremagic.com... 2014-03-24 10:09 GMT+09:00 bearophile <bearophileHUGS@lycos.com>: > if (cond) exp1, exp2; // in most case, this is not a bug. It's not a bug, but this does the same thing - so why use the comma operator? if (cond) { exp1; exp2; } It catches bugs that are otherwise very difficult to spot. |
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | Kenji Hara: > 1. I think removing comma operator does not have useful effect for tuple syntax discussion. I agree, see my recent answer to Andrei. > 2. Indeed in some case comma operator is bug-prone, but if it is used directly on the ExpStatement, it's still useful to me. > > foreach (e; exp1, exp2) {} // maybe bug? If I see a foreach like that, I refactor the code to remove the comma. Apparently I am not very good at keeping the semantics of the comma operator in my head, so I prefer to kill them in the code I work on. Bye, bearophile |
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | My vote is no, though I don't feel strongly about it since I can still get work done either way; there's alternatives to the comma operator in every case I can think of in D. But I just don't see any compelling reason to make the change. I don't find the tuple arguments convincing and the comma operator has not been a noteworthy source of bugs in my experience. The new tuple syntax need to outcompete the simple tuple() or TypeTuple!() possibilities we have today, and personally, I don't think they tuple proposals even stand on their own, much less outcompete the status quo. So again, my position is no, leaning toward meh whatever. |
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | "Adam D. Ruppe" wrote in message news:cchwhwpquenzkbuafule@forum.dlang.org... > My vote is no, though I don't feel strongly about it since I can still get work done either way; there's alternatives to the comma operator in every case I can think of in D. But I just don't see any compelling reason to make the change. The compelling reason is it catches bugs. Try it on your code, you might be surprised! |
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On Monday, 24 March 2014 at 01:48:15 UTC, Daniel Murphy wrote:
> Try it on your code, you might be surprised!
hmm, I am surprised about one thing: it didn't detect a single use of the comma operator in the ~10,000 lines of my code I fed it. I know I don't use it often, but I thought surely there'd be at least one or two uses in all that!
I'd compile my whole everything, but apparently I need to get git druntime* and phobos too for that to actually work (or patch my other dmd without getting the other changes) and meh, I don't care that much.
I guess it being even more rare than I thought moves me a bit more into "meh" territory though.
|
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Monday, 24 March 2014 at 01:16:47 UTC, Andrei Alexandrescu wrote:
> On 3/23/14, 6:09 PM, bearophile wrote:
>> Andrei Alexandrescu:
>>
>>> Discuss: https://github.com/D-Programming-Language/dmd/pull/3399
>>
>> Are you going to listen to people in this thread or are just going to
>> say that people in the newsgroup are not representative of the whole
>> community of D users?
>
> Argumentum ad populum has low pull on me. Come with good arguments, not "half a dozen people can't be wrong".
>
It is understood, but this has been discussed to death, and yourself agreed in the past that this was to be done.
The topic has been recurrent for 5 years. It could have been through the deprecation process several time by now.
Points goes as follow :
- This construct has little usefulness.
- It create hard to debug bugs (if you switch , and ; in typo for instance).
- It prevents moving forward with tuples/multiple returns value with a nice syntax.
- Most people hate it.
Why is that we need to either cast thing in stone or change by breaking everything Atila style ? The more we wait, the greater the pain.
|
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy Attachments:
| 2014-03-24 10:38 GMT+09:00 Daniel Murphy <yebbliesnospam@gmail.com>:
> "Kenji Hara" <k.hara.pg@gmail.com> wrote in message news:mailman.27.1395624482.25518.digitalmars-d@puremagic.com...
>
> 2014-03-24 10:09 GMT+09:00 bearophile <bearophileHUGS@lycos.com>:
>
> if (cond) exp1, exp2; // in most case, this is not a bug.
>>
>
> It's not a bug, but this does the same thing - so why use the comma operator?
>
> if (cond) { exp1; exp2; }
>
> It catches bugs that are otherwise very difficult to spot.
>
At least I can imagine two reasonable cases.
1. If the code is ported from C/C++, breaking it is not reasonable.
2. If the two expressions are strongly related, using comma operator is reasonable to represent the intensity. I think rather it's an *ability* to represent code meaning by using code style.
Kenji Hara
|
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Monday, 24 March 2014 at 01:36:46 UTC, bearophile wrote:
> C code should not silently behave differently in D, even five years from now, so I am not interested in using the C comma syntax for D tuples. I am OK with a D tuple syntax that is not allowed in C.
>
It won't silently break. I concede it will break.
|
March 24, 2014 Re: Should we deprecate comma? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara |
> if (cond) exp1, exp2; // in most case, this is not a bug.
>
> So, completely removing comma operator will cause negative affect in
> some cases.
>
> Kenji Hara
In this case you should use { exp1; exp2; } There's two expressions, so same number of ';' should appear and it make code more clean. I know it's personal. It's just IMHO.
|
Copyright © 1999-2021 by the D Language Foundation