David B. Serafini wrote:
>
> > From: John Reid [SMTP:[log in to unmask]]
> > Sent: Friday, November 14, 1997 6:43 PM
>
> > Additionally, a {part-name} to the right of a {part-ref} with nonzero
> > rank must not have the POINTER attribute. This is because such an
> > object would represent an array of pointers and require a very
> > different implementation mechanism from that needed for an ordinary
> > array.
>
> I don't see this as a problem that is difficult enough to warrant a
> special exemption in the standard. C has this problem in spades,
> and compiler writers deal with it without much trouble.
>
> At worst the compiler will have to recognise the special case and
> generate different code for it (not _much_ different, just one additional
> indirect reference through the array of pointers). The compiler can
> identify the special case because it knows the types of all the pieces
> at compile time.
>
> Of course it will run slower. But the programmer will know this
> when s/he writes the code. Predictable performance, even when poor, is not a
> problem in my book. It's the programmer's job to know what can be
> done efficieintly and what cannot, and to trade off with the other issues
> involved as appropriate.
>
> -David
I think that the two implementation would be _very_ different:
type test
integer :: foo
integer,pointer :: bar
end type test
type (test) zap(100)
Here one can assume a regular pattern for the storage of each foo
element, so
that one can point easily to the array zap(:)%foo.
But each bar element is allowed to point to any memory location, and
when you
point to bar you don't point to the pointer itself but to the integer
pointed by bar.
This means that zap(:)%bar would be a pointer to an array of irregularly
distributed
integers in the memory (such an array is not allowed, I guess).
In fact we need pointers to pointers to make zap(:)%bar possible .
--
-----------------------------------------------------------------------
Pierre Hugonnet, PhD Student (Geophysics) |phone: 33- 5 59 83 57 94
ELF Exploration Production, PAU (FRANCE) |fax : 33- 5 59 83 48 58
Geological and Geophysical Research Div. |mailto:[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|