Re: Array Constructors



Jan Vorbrüggen <jvorbrueggen@xxxxxxxxxxxxxxx> wrote:

Also note that I/O-implied DO variables are different. They do not have
their own scope, but are "ordinary" variables. There was once a time
when I was unaware of this distinction myself (and thus made a fool of
myself vehemently explaining something that turned out to be wrong. Oh
well. It happens).

Is there any good reason for this, apart from "this is how the vote went" (if
anybody ever noticed before it was too late" or "we put it in so that Richard
Maine would have a chance to make a fool of himself" 8-)? I can't see a
technical need for two of the implied-do-variable types to behave one way and
the third in another.

Yes, there is, unfortunately, a good reason. (Updated... Or at least a
good reason for half of the bahavior. I'm having trouble recalling th
eother half).

Implied DO indices for array constructors and DATA statements pretty
much "can't" be ordinary variables. Or anyway, if they were, one would
have to add a lot of complicated stuff laying out extra details about
tham. That's because they aren't in general done at run-time. In some
cases, array-cunstructor implied DOs can be run-time things, but in
other cases, they can't (such as when used in an initializer). DATA
statement implied DOs never are. If you tried to describe these as
variables with scope broader than the implied DO, you'd have to define
concepts of ordering... an awful lot like describing execution ordering.

As for the I/O ones. Hmm. I was thinking I recalled some reason, but it
escapes me at the moment. (No, it is not so that you can read
(a(i),i=1,n) and deduce how many elements you sucessfully got in a
too-short record by examining the value of i; that would be
nonstandard.)

Do note that both I/O and DATA statement implied do loops go "way back".
So the difference isn't something new. People wouldn't yet have had a
chance to get annoyed enough at me to want to give me the chance to make
a fool of myself. Well, my parents were probably pretty frustrated, but
that's another matter. :-)

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.


Quantcast