25 June 2000  Page 1 of 1  J3/00-239

Subject: Issue 280 From: Van Snyder References: 00-195r2

1 Introduction

Issue 280 says “ALLOCATE ( ... SOURCE = ... ) begs for an example. Here’s one.

2 Edits

Edits refer to 00-007r2. Page and line numbers are displayed in the margin. Absent other instructions, a page and line number or line number range implies all of the indicated text is to be replaced by immediately following text, while a page and line number followed by + indicates that immediately following text is to be inserted after the indicated line. Remarks for the editor are noted in the margin, or appear between [ and ] in the text.

[Editor: Replace issue 280:] 103:36-38

NOTE 6.17\frac{1}{2}

   TYPE :: LIST ! A list of anything of extensible type
     TYPE(LIST), POINTER :: NEXT => NULL()
     CLASS(*), ALLOCATABLE :: ITEM
   END TYPE POINT_LIST
   ...
   TYPE(LIST), POINTER :: IN_LIST, LIST_COPY => NULL()
   TYPE(LIST), POINTER :: IN_WALK, TEMP, PREV_COPY
   ! Copy IN_LIST to LIST_COPY
   IN_WALK => IN_LIST
   DO WHILE ( ASSOCIATED(IN_WALK) )
     ALLOCATE ( TEMP )
     IF ( ASSOCIATED(LIST_COPY) ) THEN
       PREV_COPY % NEXT => TEMP
     ELSE
       LIST_COPY => TEMP
     END IF
     PREV_COPY => TEMP
     ALLOCATE ( TEMP % ITEM, SOURCE = IN_WALK % ITEM )
     IN_WALK => IN_WALK % NEXT
   END DO

This copies the list starting at IN LIST. After copying, each element of the list starting at LIST COPY has a polymorphic component, ITEM, for which both the value and type are taken from the ITEM component of the corresponding element of the list starting at IN LIST.