(j3.2006) Parent component of extension of abstract type

Tom Clune Thomas.L.Clune
Thu Nov 12 17:01:27 EST 2015


Van,

I raised essentially the same issue a while back (2-3 years ago).   The short answer is ?Yes - this is what was intended.?

One argument is that if you could access such a parent, then you would be able to invoke methods on it.   E.g., what if there was a deferred method?   And if you don?t have any deferred methods, why does it need to be abstract?


But ? I agree that it would be nice if one could access the non-deferred items in an abstract parent.   In practice, I?ve found the situation where I miss the ability is extremely rare.

- Tom





> On Nov 12, 2015, at 4:32 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:
> 
> It seems a bit strange that I can't access the parent component of an
> object of a type that is an extension of an abstract type, but I can
> access components of the parent component.  Is this what we intended?
> 
> program P
> 
>  type, abstract :: T0
>    integer :: N = 42
>  end type T0
> 
>  type, extends(t0) :: T1
>  end type T1
> 
>  type(t1) :: V1, V2
> 
>  print '(a,i0)', 'V1 ', v1
>  print '(a,i0)', 'V1%T0 ', v1%t0      ! Prohibited
>  print '(a,i0)', 'V1%T0%n ', v1%t0%n
> 
>  v2 = v1
>  v2%t0 = v1%t0                        ! Prohibited
>  v2%t0%n = v1%t0%n
> 
> end program P
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Thomas Clune, Ph. D. 	<Thomas.L.Clune at nasa.gov>
Software Infrastructure Team Lead
Global Modeling and Assimilation Office, Code 610.1
NASA GSFC		
MS 610.1 B33-C128
Greenbelt, MD 20771
301-286-4635













-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20151112/b0f1ae3a/attachment-0003.html 



More information about the J3 mailing list