Print

Print


Aleksandar Donev writes:

 > Fortran has a somewhat rule (strange as in I am not sure how the
 > processor can inforce it, though I don't think it has to anyway--it is more a user's
 > responsibility to insure this) that one *can* use a pointer to deallocate a space
 > through a pointer which was not really used to allocate it, but *only* if it is
 > associated with the *whole* of the object.

Not so strange if you think about it in the right way.  It's not so
much a matter of the procesor enforcing it as that the job might not
be doable at all (or might not make sense), depending on the
underlying implementation.

If you allocated an array of, say, 10 elements, would you really
expect the processor to have any idea of how to deallocate a pointer
that pointed to, say, elements 5:7?  THat would be a pretty big burden
to require that to be abl eto work.

Even if you had a pointer pointing to the first two elements, such
that it might realistically be diable, realize that something is going
to have to know how much space was allocated or a deallocate just
isn't going to work.  That something may well be internal to the
allocation bookkeeping, but the information better be somewhere.

And then there is the question of what makes sense.  What would you
expect a deallocate of part of an array to do?  As a user, I'd be
quite surprised if I did a deallocate of a single element and the
whole array went away.  Is that what you'd expect?  I think that is
very counter-intuitive.  On the other hand, the underlying
implementation is unlikely to be able to support deallocating
individual elements out of an array allocated as a whole.

--
Richard Maine                |  Good judgment comes from experience;
[log in to unmask]   |  experience comes from bad judgment.
                             |        -- Mark Twain