(j3.2006) 08-267

Van Snyder van.snyder
Wed Sep 24 13:45:15 EDT 2008


Jim Xia wrote:
>
> j3-bounces at j3-fortran.org wrote on 09/23/2008 10:48:38 PM:
>
> > This means we should prohibit
> >
> >   class(my_type), intent(in) :: x[*]
> >   select type ( x )
> >   type is ( my_extension )
> >     print *, x[1]%extra_stuff
> >   end select
> >
> > because the dynamic type of X might be different from the type of
> > X[1].  Or... we should prohibit SOURCE= and MOLD= for coarray 
> allocations.
>
> Hmm..., I don't even understand what this code fragment means: the 
> associate name, x, in the select type construct is revering to a local 
> variable, and it says if it is my_extension, then refers to 
> extra_stuff on image 1?  I think we should prohibit coindexed objects 
> with base-object being associate name.
>

More details:

  type :: my_type
    integer :: stuff
  end type my_type
  type, extends(my_type) :: my_extension
    integer :: extra_stuff
  end type my_extension

The associate name x in the SELECT TYPE statement is not referring to a 
local variable.  8.1.3.3 says that the associate name has the same 
corank as the selector, so x is a coarray within the TYPE IS ( 
my_extension ) block.

> > The problem is that without being able to reference coindexed
> > polymorphic objects, e.g. as
> >
> >   select type ( x=>x[1] )
> >   type is ( my_extension )
> >     print *, x%extra_stuff
> >   end select
> >
> > and without SELECT TYPE as above, the only components that can be
> > accessed are those of the declared type.  So we might as well
> > prohibit declaring polymorphic coarrays.
>
>
> The restriction probably is not needed.  You can achieve the same 
> effect using coarray dummy arguments, which normally is more efficient 
> than using coindexed objects.  On the other hand, I have no objection 
> to disallow polymorphic coarrays:-)
>

The restriction is not needed, but it's simpler than the proposed C616a, 
which has the effect of making it pointless to declare polymorphic coarrays.

You absolutely cannot achieve the same effect using coarray dummy 
arguments.  They're still coarrays, and as soon as you give an image 
index they're coindexed objects.  If you can't get at the dynamic type 
of a coindexed object using SELECT TYPE there's no way to access the 
components of its dynamic type.

> Cheers,
>
>
> Jim Xia
>
> RL Fortran Compiler Test
> IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
> Phone (905) 413-3444 Tie-line 313-3444
> email: jimxia at ca.ibm.com
> D2/YF7/8200 /MKM
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>   




More information about the J3 mailing list