Skip to content

Commit b15801a

Browse files
Update augmented_assignment.txt
1 parent 7a33574 commit b15801a

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

augmented_assignment/augmented_assignment.txt

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
To: J3 J3/XX-XXX
22
From: Leonard Reuter
33
Subject: Augmented Assignment Operators
4-
Date: 2021-November-1
4+
Date: 2022-July-11
55

66
Proposal for Fortran Standard: 202y
77

@@ -18,7 +18,11 @@ In the same manner, the operators `-.=`, `*.=`, `/.=`, `**.=` are proposed
1818
to be defined as well as the operator `.op.=` for a user-defined operator
1919
`.op.`.
2020

21-
This proposal originated at the J3 GitHub repository at [1].
21+
The intrinsic interpretation of e.g. '+.=' can not be overridden but should
22+
always call 'operator(+)' and 'assignment(=)'.
23+
24+
This proposal originated at the J3 GitHub repository at [1]. The proposed
25+
syntax originated from a comment by Reinhold Bader in the J3 mail list [2].
2226

2327
2. Motivation
2428

@@ -38,8 +42,51 @@ If the above example were to be written without augmented assigment, how
3842
often `get_index` is called would depend on the compiler.
3943

4044
The dot is added between the operator and `=`, since `/=` is already in
41-
use.
45+
use as an alias to the '.ne.' relational operator.
46+
47+
3. Discussing Objections
48+
49+
3.1. Conflict with '/=' [4]
50+
51+
This is circumvented by introducing the dot, i.e. '/.='
52+
53+
3.2. The compiler can optimize 'a = a + b*c' better than 'a +.= b*c' [5]
54+
55+
"What happens to 'a += b * c' is often optimized to an FMA if the compiler
56+
flags or defaults allow ISO/IEEE violation" [6].
57+
58+
3.3. Instead of augmented assignment, an additional symbol can be
59+
introduced to replace the LHS [7,8]
60+
61+
If this symbol were '.LHS.', it would allow for further simplification:
62+
63+
real :: a
64+
...
65+
a = LOG(a)
66+
67+
could be replaced with
68+
69+
real :: a
70+
...
71+
a = LOG(.LHS.)
72+
73+
While discussing this may prove worthwhile, it lacks the intuitivity of
74+
simple augmented assignment and should be discussed independent of it.
75+
76+
3.4 Cognitive load [9]
77+
78+
Most programmers are used to augmented assignment from other languages,
79+
it is more cognitive load to remember, that this is not possible in
80+
Fortran than to actually use it.
4281

43-
3. References
82+
4. References
4483

4584
[1] https://github.com/j3-fortran/fortran_proposals/issues/113
85+
[2] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013261.html
86+
[3] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013251.html
87+
[4] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013254.html
88+
[5] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013262.html
89+
[6] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013279.html
90+
[7] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013287.html
91+
[8] https://wg5-fortran.org/N1951-N2000/N1972.pdf
92+
[9] https://mailman.j3-fortran.org/pipermail/j3/2021-August/013277.html

0 commit comments

Comments
 (0)