On Mar 10, 2004, at 5:22 AM, Russell, Richard wrote:
> No, I didn't try TRANSFER. I actually had to look it up to see what it
> does, and it still isn't totally clear to me. It seems to be a "move"
> of sorts, and is something that was added in Fortran 95.
Fortran 90. It just copies the bits. Seems like it ought to be
trivial at first glance.
But in practice it is a very common source of compiler bugs and often
surprisingly
inefficient. Plus ugly and syntactically obscure.
And it doesn't apply at all to some cases; it is a function, just like
any other function
in important basic ways. The most important and basic is that it takes
arguments and
gives result values. As a result you can't use it to receive values,
such as intent(out)
arguments.
> Perhaps someone familiar with the equivalence issue can explain why
> equivalence of character and non-character entities is not allowed in
> the standard, particularly since doing so can be implemented by a
> compiler;
I've written this same explanation at least one other time real
recently, but it
might have been in comp.lang.fortran instead of here.
No rocket science here; the answer is simpler than you'd think, but you
have to think in
terms of standards. Standards are about the same code meaning the same
thing in different
places. When something is nonstandard, it can be for several reasons
and some of them have
nothing to do with being unimplementable. Sometimes it just means that
different
implementations will give different results and the standard is written
to avoid
constraining the implementation. That's the case here.
Different implementations have different relationships between
character and numeric
sizes. We don't need to get into complications like whether they are
even multiples
or not, just that they are different. Thus the equivalence lineup ends
up being
different and you'll get different results on different machines. In
the case of
equivalence differences like this, those different results aren't just
different
values for the same variable; you can end up changing different
variables.
Thus it isn't surprising that some compilers allow this. It isn't at
all hard to
do. What is hard is to make it mean the same thing in different
environments.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|