(j3.2006) [Re: Types need a "self" component ]
Van Snyder
Van.Snyder
Fri Dec 18 20:24:06 EST 2015
On Dec 17, 2015, at 9:29 PM, Van Snyder <van.snyder at jpl.nasa.gov>
wrote:
> > It's not possible to assign to a nonallocatable polymorphic object, or
> > to the declared-type part of it, without mentioning all the components
> > of the declared type individually, even if the class is not abstract.
>
> > If a type had a nonpolymorphic "self" component of the same name and
> > type as itself, encompassing all its components in the same way a parent
> > component encompasses all its components, it would be possible to assign
> > to the declared-type part of a polymorphic object, without mentioning
> > all the components individually.
> >
> > type :: T1
> > integer :: A
> > integer :: B
> > ...
> > integer :: Z
> > end type T1
> >
> > class(t1) :: V1
> > type(t1) :: V2
> >
> > v1 = v2 ! prohibited
> > v1%t1 = v2 ! would be nice, but we didn't do it
> I thought that
> select type (V1)
> type is (t1)
> v1 = v2
> class default
> v1%t1 = v2
> end select
> was designed to handle this type of problem.
v1%t1 = v2
never works, because the declared type of v1 does not have a t1
component, no matter what its dynamic type is. If the declared type of
v1 were an extension of t1, it would work.
More information about the J3
mailing list