[J3] Why is += missing?

Ondřej Čertík ondrej at certik.us
Thu Sep 2 20:28:24 UTC 2021


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