1
1
To: J3 J3/XX-XXX
2
2
From: Leonard Reuter
3
3
Subject: Augmented Assignment Operators
4
- Date: 2021-November-1
4
+ Date: 2022-July-11
5
5
6
6
Proposal for Fortran Standard: 202y
7
7
@@ -18,7 +18,11 @@ In the same manner, the operators `-.=`, `*.=`, `/.=`, `**.=` are proposed
18
18
to be defined as well as the operator `.op.=` for a user-defined operator
19
19
`.op.`.
20
20
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].
22
26
23
27
2. Motivation
24
28
@@ -38,8 +42,51 @@ If the above example were to be written without augmented assigment, how
38
42
often `get_index` is called would depend on the compiler.
39
43
40
44
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.
42
81
43
- 3 . References
82
+ 4 . References
44
83
45
84
[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