This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, fortran] Preliminary patch for derived type extension
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "Tobias Burnus" <burnus at net-b dot de>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Thu, 24 Jul 2008 20:28:48 +0200
- Subject: Re: [Patch, fortran] Preliminary patch for derived type extension
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=zHS7UtXnRFUCXSZHm0qIeSy1/6vWgLyHmIpFtqXOQCE=; b=TvrvhJH1e1dSzWs52rUXA9TfX8GAMTyhb8Eqhk71b6vOvlCH2sEPW4JOQKqnzM27N3 8O0gBdW8mKDzrsFsYwNZ17PKJ8czcnY13vnsu7JnN+5NvhF7ardYI1h4jDffzoJCeSs5 cwEC5Dgr5eTb/01prcWe4sF9mlJ4GeJqI9LS8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=wVXsDhy20JT46dUpbT7JREWqIUZWnOt9LWNfWBsUORahgZEPE1KGrzWPUJCVVqMEAY HClltXjaTOUjXwG+E64eFfuBXFVfiJyzgT/DzS3DAZnlfqTw1nMEmPxV4o+xnNzdDafY 6012qxRfVEYRP57L5/drsxMrYdzbbQXcWFY7Y=
- References: <339c37f20807221459i32983648n2a7a15b16d6edd15@mail.gmail.com> <4888C354.9050409@net-b.de>
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