Toon Moene writes:
> > 1. When you _really_ want a pointer, e.g. for a linked-list.
>
> > 2. When you want an allocatable component of a derived type.
> I'm coming a bit late in this conversation (been attending a workshop at
> the UK Met. Office the last few days) - but isn't (1) just a specific
> example of (2) ?
Not at all. Indeed almost the opposite. In (1) you really want a
pointer because it needs to point to something else, as in a linked
list.
In (2) you do not partcularly want a pointer. In fact the pointerness
just gets in the way. All you want is a component whose size may vary
from object to object (or possibly over time in a single object). You
never want it to point to some other copy. And you never want two
different objects pointing to the same thing. Each object has its own
unique component. You really want an allocatable component. The only
reason you'd even consider using pointers for this is because there
are no allocatable components in f90/f95, so you have to make do with
pointers.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|