On Oct 17, 2005, at 1:07 AM, O'Brien Paddy wrote:
> The repeat factor which is available in DATA statements is not
> available in array constructors...
> Is there a particular reason that the repeat factor has been excluded?
The syntax of DATA statements is generally quite quirky. It is
completely different from the syntax of anything else and, in general,
doesn't work out well in other contexts. That is one reason that I
generally avoid DATA statements, but on occasion there are things that
just turn out to be difficult to do any other way.
The repeat factor is one cause of some of the oddities in DATA
statement syntax. Consider something like
6*7
In any context other than a DATA statement, that means 6 times 7. The
DATA statement does not allow arithmetic, even the most trivial cases
like that. Pretty much every other context does allow arithmetic and
thus, repeat factors wouldn't work. Certainly 6*7 is a perfectly valid
value for an array constructor element, for example. One could perhaps
start defining a lot of special-case rules for when 6*7 meant
multiplication and when it meant repeats, but that would get very
complicated very fast - I can't imagine that being a good road to go
down.
As Mike says, you can use implied DO loops. They are quite a bit
wordier, I realize, but they ought to work for the purpose.
Much more painful in terms of replacing DATA statements is figuring out
what to do for cases where you want only part of an object initialized.
This can come up in many ways, one of the most vexing being when the
object is of a type that does not allow initialization of some
components. Sometimes there just isn't a way to do this other than with
a DATA statement or an executable statement.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|