Paddy wrote:
>>I like Robin's suggestion of (6)7 as a replicator. Can this go into
>>a suggested item for 2020 :-) Fortran? Credit to Robin.
Why the new syntax? What's wrong with using DATA statements?
As I see it, there are at least two convenient run-time ways to
"initialize" (define, really) variables before using them, the
assignment statement and READ. When you want to define an array
with tables of values, READ is a good choice (except it requires the
overhead of I/O). Embedding an input file in the source file is a
useful feature if a language allows it.
For compile-time initialization, there are initialization
expressions and the DATA statement. Initialization expression in
type-statements is modelled after the assignment statement, while
the DATA statement looks more like list-directed READ, it seems
(implied-DOs, repeat factors), with the input data embedded in
source file.
"Fortran 77 permitted a processor to supply more precision derived from
a real constant than can be represented in a real datum when the constant
is used to initialize a data object of type double precision real in a
DATA statement." ("Fortran 77 compatibility" section in the standard)
..which seems natural if you think of DATA statements as a
compile-time version of list-directed READ, but unnatural if you
think of it as a list of literal constants (Fortran 90 took the
later view, of course).
Anyway, what I want to say is, initialization expressions and DATA
statements fulfill different roles; DATA statements aren't necessarily
just redundant obsolete ways of writing initialization expressions,
think of it as a way to do READ at compile time, convenient for
filling tables of values, if you need to.
--
Yasuki Arasaki
[log in to unmask]
|