[J3] Why is += missing?

Brad Richardson everythingfunctional at protonmail.com
Wed Aug 25 12:44:33 UTC 2021


The most compelling "argument" I've heard against adding them is that /= is already taken for not equals. I.e.

var /= denominator

is difficult to distinguish from

if (var1 /= var2) ...

I'd think that it would be possible for compilers distinguish between the two, as they aren't allowed in the same places, but the vendors seem to have so far disagreed. And it's possible I just haven't understood some legitimate reason they conflict in the BNF (i.e. some cases where parsing is truly undecidable).

Brad

On Wed, 2021-08-25 at 12:36 +0000, Jeff Hammond via J3 wrote:

> Yes, although I’m not going to fight for “**=”.
>
> NWChem has a few thousand instances where += and -= would be used.
>
> Jeff
>
> From:Klemm, Michael <Michael.Klemm at amd.com>
> Date: Wednesday, August 25, 2021 at 3:33 PM
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Jeff Hammond <jehammond at nvidia.com>
> Subject: RE: Why is += missing?
>
> External email: Use caution opening links or attachments
>
> [Public]
>
> I guess for completeness you would also like to see the other variants such -=, *=, etc.?
>
> Kind regards,
>
> -michael
>
> From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf OfJeff Hammond via J3
> Sent: Wednesday, August 25, 2021 14:08
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Jeff Hammond <jehammond at nvidia.com>
> Subject: [J3] Why is += missing?
>
> [CAUTION: External Email]
>
> I’m sure this is obvious to everyone else but I am new here.
>
> After 15 years as a Fortran programmer, I am still annoyed on a daily basis about the tedium imposed on me because Fortran lacks +=.
>
> One of countless examples is below. The duplication of snsi and sisn right and left of the = is not only tedious and wastes many columns – sorry, but many of my projects are still fixed source-form and enforce 72 column limits – but error prone since any manipulation of the array indices must be done twice.
>
> do ii=1,nocc
> do l=1,nfl
> do j=1,nfj
> do i=ilo,ihi
> do k=klo,khi
> int1=eri1(l,k,j,i)*factor
> int2=eri2(j,k,l,i)*factor
> snsi(i,j,l,ii)=snsi(i,j,l,ii)+t1ao(k,ii)*int1
> snsi(k,j,l,ii)=snsi(k,j,l,ii)+t1ao(i,ii)*int2
> sisn(k,l,j,ii)=sisn(k,l,j,ii)+t1ao(i,ii)*int1
> sisn(i,l,j,ii)=sisn(i,l,j,ii)+t1ao(k,ii)*int2
> enddo
> enddo
> enddo
> enddo
> enddo
>
> I have not kept track but I suspect I’ve wasted many hours of my life debugging copy-and-paste errors related to the fact that I cannot do the obvious thing and use +=.
>
> I am very curious what benefit the Fortran community has derived from the lack of support for += that justifies my suffering.
>
> Thanks,
>
> Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210825/d74e0b26/attachment-0001.htm>


More information about the J3 mailing list