Hello everyone,
Line continuations without & would be extremely useful for many things in Fortran.
- Declaring arrays, and calling large methods.
- Declaring
associate
blocks, without accidental mistakes.
And many … many different things.
Although, I slightly disagree with how others are proposing to solve this.
Many well respected Fortran community members propose an “implicit” method of solving this issue, where line continuation would be implicitly assumed, for special cases, such as arrays, function statements etc.
Such a proposal is this: Implicit line continuation · Issue #130 · j3-fortran/fortran_proposals · GitHub
I slightly disagree with this, because it is a specific solution, to a specific problem of line continuation for arrays, where as we need a general solution that works for every line continuation issue that might occur, in older and future Fortran standards.
We need an explicit multi-line continuation command.
A simple example of an explicit multi-line continuation command would be to use &*
and *&
similar to how C/C++ uses /*
and */
for declaring multi-line comments.
x = [ &*
1, 2,
3, 4, 5,
6, 7,
8] *&
associate ( &*
cells => mesh%cells,
nodes => mesh%nodes,
nc => mesh%num_cells,
nn => mesh%num_nodes ) *&
Since this is an explicit multi-line continuation command, this will work forever for all future Fortran standards, and with very minimal complexity for compiler developers.
This is just a basic idea, and I don’t have any strong opinions on the syntax of &* *&
, so if other Fortran devs have an alternative syntax in their mind, I would humbly request them to share their ideas.
Thanks!