This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] Preliminary patch for derived type extension


Tobias,


> Works quite well. When doing some tests, I found that the following does not
> work as expected:
>
> ----------------
> module m
> type :: date
> private
> integer :: yr, mon
> integer,public :: day
> end type
> end module m
>
> use m
> type, extends(date) :: datetime
> integer :: hr, min, sec
> end type
> type(datetime) :: o_dt
> o_dt%day = 5  ! VALID but fails
> o_dt%yr  = 5  ! INVALID, but not so helpful diagnostics
> end
> ----------------

OK - I'll fix these.

>> (ii) I am not sure, as in comment #2, if a renamed, use associated
>> parent type should appear as a component with the new name or the
>> original.  This is trivially corrected if it is incorrect as it
>> stands.  I have not had time to check the standard for correct usage.
>> If anybody knows which is right, please let me know.
>>
>
> Good question. The current behavior of gfortran is the same as NAG f95. Both
> compile the following.
>
> I now asked at c.l.f as I cannot make head or tail of the standard. Somehow
> both makes sense. I had hoped that the corrigenda contain something, but I
> could not find anything there either. See:
>
> http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/de0078ccba15163d

Thanks - I'll leave it as it is for now.

I have a fix for the constructors that I have just seen how to make
much more economical in extra code.  I'm on line for a definitive
submission, as anticipated.

Cheers

Paul


>
> ---------------------
> module m
>  type mod
>   integer :: i = 1
>  end type mod
> end module m
>
> use m, only: local => mod
> type, extends(local) :: my
> end type
> type(my) :: t
> t%mod = local(1)
> end
> --------------------
>
> Tobias
>
> PS: I found a nice Fortran 95/2003 OOP
> introduction/overview/comparison-with-C++ at
> http://www.lrz-muenchen.de/services/software/programmierung/fortran90/f03_material/
>  However, it is not that helpful if you are looking for examples for the
> testsuite.
>



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
 --Hitchhikers Guide to the Galaxy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]