James Giles wrote:
> So, such linked structures would be designed
> using indices into these arrays instead of using POINTERs at all
> (I have no present intention to include POINTERs in my langage).
OK, thanks for the comments, they are useful. But we disagree here,
since I don't harbor negative feelings against POINTERs (after all,
they are integers into the virtual memory system, so not much different
from an index as you prefer). The advantage of having a POINTER-based
structure is that one can at first easily use the compiler's runtime
allocator, and then later add other allocators as necessary. It also
enables a minimal coupling between the memory allocator and the
structure itself (in my own example, which yes, is more complex, I need
to store the page for each node because Fortran does not support
C-style array pointers, which are necessary to implement skipped lists
efficiently, but it does not need to be done in general) and IMO makes
code look simpler (unless one uses preprocessors, in which case one can
make integers act like pointers too).
But yes, the system you describe definitely has its advantages also.
Ideally one would want to support both with minimal overhead and
complexity at the code level. Maybe using a derived type
TYPE(Pointer_To_Node) instead of an actual "TYPE(Node), POINTER" is a
good way to do this...Fortran is still far from having good language
support to actually do all this, but I am thinking here about Fortran
20xx (with genericity, accessors and updators, overloading pointer
assignment, etc.).
Best,
Aleks
|