> > > 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.
I've used both pointers and allocatables, but in a very basic way. I
have no experience with either in any language but standard Fortran
(i.e. not Cray pointers, VAX extensions etc---I love the VAX compiler
but tend to write standard-conforming code). Perhaps someone can clear
up some confusion at a rather basic level.
To me, it seems that pointing to an object and having the size
determined at run time are two such completely different concepts that
I'm wondering why the former is used for the latter at all. I realise
that there is a low-level reason for this in a technical sense, but
using the same type of construction for both seems really off the wall.
As such, I'll be happy when one can make a high-level decision to use
pointers or allocatables according to what is really needed.
When the present kludges are no longer necessary, what about making them
obsolete and then deleting them? Otherwise, they are bound to cause
much more confusion than the FORTRAN IV stuff still kicking around.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|