Alvaro Fernandez writes:
> In F95, can an initialization expression in an automatic array be a
> user-defined function?
Yes. It is a specification expression, which can include some
user-defined functions.
> the value of automin would depend on a SAVE'd
> quantity, which makes the function not PURE.
That's not really what the definition of PURE says, but its somewhat
of a side issue because you are not only "depending on" a SAVE'd
quantity, you are also modifying it, and that's not allowed.
Yes, "of course" the function has to be pure. This is one of the
things pure functions were made for. Perhaps the main point of purity
is to avoid dependence on order of execution, so you need it in places
where the order of execution isn't defined. That includes whole array
expressions (elementals), declarations, and FORALL. You don't want to
try to define an "order of excution" of declarations. Well, perhaps
you do. It is something that could in general make sense and be
useful, but you'd have to throw out most of Fortran's declaration
syntax to make such a thing work plausibly (mostly the way in which
attributes can be specified in a bunch of different places, or even
inferred from usage in the subsequent executable code). Much as it
might "clean up" the language to revamp all this, there is a "minor
matter" of compatability with 99% of all existing code. I don't think
we are going to see such a change during my career...or even during
that of some of you younger folk.
This whole approach to automatic arrays, however, seems to me of
pretty small value. One of the biggest advantages of automatic arrays
is simplicity. If you are going to this much complication, it seems
to me to make more sense to just use allocatables. I think you are
putting together a scheme more complicated than allocatables rather
than less complicated.
I suppose in f90, one could argue that autmatic deallocation of
automatics was still a benefit, but in f95 you have that for
allocatables also (and if you stick to f90, you don't have
user-defined specification functions at all).
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|