Path: utzoo!attcan!uunet!yale!cmcl2!lanl!jlg
From: jlg@lanl.gov (Jim Giles)
Newsgroups: comp.lang.fortran
Subject: Re: Data types _without_ pointers
Message-ID: <4096@lanl.gov>
Date: 23 Sep 88 21:41:06 GMT
References: <1580@ficc.uu.net>
Organization: Los Alamos National Laboratory
Lines: 35

From article <1580@ficc.uu.net>, by peter@ficc.uu.net (Peter da Silva):
> 	struct {
> 		struct list *prev, *next;
> 		data;
> 	} *p, *q;
> 	...
> 	q->next = p;
> 	p->prev->next = q;
> 	q->prev = p->prev;
> 	p->prev = q;

How about (in Fortran-like syntax):

      type dlink
         integer data
         dlink :: next, prev       !recursive data declaration
      end type dlink

      dlink :: p, q
      ...
      q%next = p                   !Fortran 8x uses % for the structure ref
      p%prev%next = q              !I know!  I don't like % either
      q%prev = p%prev
      p%prev = q

No pointers!  Only variables of type 'dlink'.  The advantage is that
type checking will prevent me from assigning any address other that
another variable of type 'dlink' to any of the links.  With pointers,
type checking is not performed (if it is, then some of the really useful
things that pointers can do are lost) - I am stuck with the possibility
of a link in my list pointing off into left field.  I only want _that_
to be possible if I really might want to point into left field.

J. Giles
Los Alamos