[J3] [EXTERNAL] Re: Why is += missing?
Clune, Thomas L. (GSFC-6101)
thomas.l.clune at nasa.gov
Thu Sep 2 21:13:19 UTC 2021
Ondrej,
I pretty much agree with the metric you introduce here, but with a couple of caveats.
1. The "number of uses" may not be a linear factor. For the moment I think it is fair though.
2. "how much it saves" is very subjective.
Note: I suspect the opportunities for the ? case with N=2 options is probably not very rare, but the savings are also not particularly strong in that case. And you may not ever have had the N=4 case like Van. I've only had that 2-3 times in my career. But the workaround without ? is dreadful and arguably quite difficult to understand/maintain. And I'm sure there are (rare) cases out there with N > 4. A person could very easily oppose the feature on those grounds. As a former president once said though, votes matter. WG5 decided that this feature should be pursued.
Cheers,
- Tom
On 9/2/21, 4:28 PM, "Ondřej Čertík via J3" <j3 at mailman.j3-fortran.org> wrote:
Hi Malcolm,
On Thu, Sep 2, 2021, at 1:10 AM, Malcolm Cohen via J3 wrote:
> Ondřej Čertík writes:
> > Given the number of lines that could use +=, it seems the number of lines that could use ? is orders of magnitude less, or is that not the case?
>
> Others have replied to this, but anyway:
>
> Conditional expressions turn multiple statements into one expression.
> As Van said, the alternatives to op= are trivial.
> They are so far apart as to be not comparable in functionality.
>
> Some might even disagree that “var op=expr” is clearer than “var=var op expr”.
It's a good point that the alternative to "+=" is simpler than the alternative to "?". Van made the same point.
So a better metric might be: (number of uses) * (how much it saves)
"+=" saves less, but is used a lot.
"?" saves more, but is used less.
In one of my codes I ran the "grep" command from the thread above and obtained ~600 cases where it could be used, consistent with others who posted. I can't think of a single case where I would use "?", so for me the metric above clearly wins for "+=".
I have no doubts that others would find more uses for "?", so perhaps "?" can win in the above metric for them.
>
> > The new ? operator is exactly like in C. As a committee we have decided that was the best approach from all the alternatives.
>
> Did I not mention how much I disliked the syntax the committee voted
> for? Not sufficiently to change my vote, but I was quite disappointed.
Fair enough.
>
> > I would encourage us to be open minded about adding +=.
>
> I try to be open-minded about all new features, with the caveats
> 1. All new features start with minus 100 points.
I do the same.
> 2. I try to think of as many obvious problems as I can at the start,
> so we’re not surprised by them later. (Even so, I frequently miss
> problems that ought to have been obvious!)
>
> Fortunately, there’s loads of time for people to think about this
> particular suggestion before we get to formal submission of a proposal.
Thank you,
Ondrej
More information about the J3
mailing list