> Unfortunately, I'm away from base for three weeks so will have to try to get a reply to you by other means. However, I note that at
ftp://ftp.numerical.rl.ac.uk/pub/MRandC/ the most recent version of edits.pdf is 24 March, 2013 and the most recent version of oo.f90 is 30 October, 2014.
>
>
>
> Watch this space.
>
I'm sorry that it has taken so long to reply definitively to your message,
but holidays are now drawing to a close and I hope the following clarifies
the situation. In fact, several corrections to oo.f90 are called for, and
maybe I could ask you to post them too on the intel site.
Firstly, we do not agree with yamajun when he says
> Dummy argument "item" is alias to "list%firstptr"
> (actual argument of SUBROUTINE DELETE_LIST).
They are not aliases - they are pointers with the same target. Also
> This means the line
> "list%firstptr => item%nextptr" is the same as
> "item => item%nextptr".
Again no, as this is just changing the target of list%firstptr.
Unfortunately, there is no explanation of why temp is needed in subroutine
delete. It is because a passed-object dummy argument is not allowed to be a
pointer. However, we assume that item was created by allocation of a
pointer target and want to deallocate it. Hence the use of the pointer
temp that points to it.
But, in fact, it turns out that subroutine delete is anyway wrong, although
it will work on most if not all compilers.
The reason is that you should not be able to
destroy a dummy argument, although the standard contains no such actual
prohibition (something we will follow up). Taking account of all this, the
following changes ensure that it should work in all circumstances. The
downloadable code has been updated at
ftp://ftp.numerical.rl.ac.uk/pub/MRandC/oo.f90.
433:-3 Add "delete," after "anyitem,".
434:middle. Change line
procedure, non_overridable :: delete
to
! delete has a pointer argument so cannot be type bound
437: a third of the way down. Change lines
class(anyitem), target :: item
class(anyitem), pointer :: temp
temp => item
call remove(item)
deallocate (temp)
to
! We want to deallocate the dummy argument, so it must be a pointer.
! It follows that the procedure cannot be a type-bound procedure.
class(anyitem), pointer :: item
call remove(item)
deallocate (item)
440:middle. Change line
call p%delete
to
call delete(p)
Thank you for drawing this to our attention.
Mike Metcalf