[J3] [EXTERNAL] Re: Why is += missing?

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Fri Sep 3 12:33:56 UTC 2021


Hi Malcolm,

I definitely see some arguments on both sides of whether “+=” would be shorthand vs a new operator.      We already have the annoying “/=” is not the same as “.not. ==”, requiring numerous (short) trivial implementations of “/=” scattered throughout many layers of code that I write.

Maybe I’ve not properly understood your point though, as I don’t see how it _undermines_ existing modules. Those + and = implementations remain valid.    They just would not automatically confer the new “+=”.   And in this hypothetical future, new generic programming facilities might make it rather simple to augment those implementations.       Were it possible, I’d want my proverbial cake after eating it: where “+=” derives from “+” and “=”, with the option to override.   I’m guessing there’s a gotcha somewhere for that, or you would have suggested it.

And I agree that a single-statement form of associate would appear to be a more general/useful, less-disruptive approach to this.     But even there, I suspect that by the time we look at real world cases that are messy enough to warrant the use of an alias, the existing ASSOCIATE will actually be clearer.     (Advocates: start collecting real world examples to make your case!)

It might be nice to start a collection on the GitHub site of snippets of seemingly irreducibly complex code.   I suspect that in many cases (but certainly not all) additional eyes may find clever ways to significantly improve code quality without introducing any new features.     (And in my mind, this is not about counting lines of code.   If short, obvious helper-procedures can allow the main work to be written clearly and concisely, it may actually/often increase the number of lines of code.)

Cheers,


  *   Tom

From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of j3 <j3 at mailman.j3-fortran.org>
Reply-To: j3 <j3 at mailman.j3-fortran.org>
Date: Thursday, September 2, 2021 at 8:26 PM
To: j3 <j3 at mailman.j3-fortran.org>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: Re: [J3] [EXTERNAL] Re: Why is += missing?

> If we decide to go down this path, then I would very firmly want “+=” to be a distinct assignment operator and allow user defined operations using ASSIGNMENT(+=).

I understand why you’d want to do that in some cases, but it undermines existing modules that provide assignment just plus, or assignment and plus (there not being any that provide the new one anyway!). That is the opposite of protecting existing investments.

A single-statement form of ASSOCIATE would certainly be less disruptive than this. We already have single-statement forms of not just IF, but WHERE, and FORALL; the latter already has statement entities (the index variables) just like a single-statement form of ASSOCIATE would have.

Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210903/0e89e66e/attachment.htm>


More information about the J3 mailing list