Print

Print


To Malcolm Cohen

I admit that, when the TYPE,EXTENSIBLE TYPE,EXTENDS() and CLASS
instructions will be available, I'll can do, practically, without
my TEMPLATE instruction but the conceptual and operative
difference between the two methods seems to me such as
to make "interesting" the availibility of my TEMPLATE
along side  the other instructions.

It will not be a duplicate ! With TEMPLATE I could exploit
FORMAL similitudes in the derivate type declaration.
Some functions could exist that are outside the classes
but, for some coincidences matters, can be used from
many classes.

I note that the TEMPLATE proposal take advantage from
my enhanced ASSOCIATE instruction existence ( associate(*=>...%*) ).
If I write:

call rotation(point%x, point%y, point%z)

and I define:

subroutine rotation(x,y,z)
   real::x,y,z
   ...x*cos(phi)-y*sin(phi)...
   .....

in some way I use an ASSOCIATE external to the "rotation"
subroutine. Instead, if I write:

call rotation(point)

and I define:

subroutine rotation(p)
   template(point)::p
   associate(*=>p%*)
   ...x*cos(phi)-y*sin(phi)....
   .....

I use an internal ASSOCIATE. This allow me to make the CALL
more readable and simple.

Let me do a daring comparison: my proposal consist, in a
figurative sense, into allowing, besides the marriage between
two types of data, even the free sex but with some
suitable precautions (witout wrong memory access).
The analogies between the two types of relationships are
strong but the differences are important too ;-).

Best regards

           Giampaolo Bottoni




In 10.42 06/12/00 +0000, hai scritto:
>Giampaolo Bottoni said:
>> The f2k PDF draft is a book of more than 400 pages!  :-(
>
>So we are about halfway between the F95 standard (355 pages) and
>the C99 standard (554 pages).  Big deal.
>
>> Using template:
>>
>> type::point
>>     real ::x,y,z
>> end type point
>> type :: event
>>     real:: x,y,z,t
>> end type event
>>
>> type(event)::bigbang
>>
>> subroutine rotation(p)
>>    template(point)::p    !!! Hic sunt leones (old Latin maxim)
>>    ...
>> end subroutine rotation
>>
>> call rotation(bigbang)  !!! CORRECT,RIGHT !!!
>>
>> Please, may you briefly explain to me (and, why not, to all the
>> [log in to unmask] members) how can I obtain
>> the same effect using the new and powerful object
>> oriented f2k instructions ?
>
>MODULE points_and_events
>  TYPE,EXTENSIBLE :: point
>    REAL x,y,z
>  END TYPE
>  TYPE,EXTENDS(point) :: event
>    REAL t
>  END TYPE
>CONTAINS
>  SUBROUTINE rotation(p)
>    CLASS(point) p
>    ...
>  END SUBROUTINE
>END MODULE
>PROGRAM example
>  USE points_and_events
>  TYPE(event) bigbang
>  ...
>  CALL rotation(bigbang)
>  ...
>END PROGRAM
>
>> The type event must be of necessity an extension
>> of the type point ?
>
>Yes.
>
>There was some tutorial material about these facilities published in
>Fortran Forum:
>
>"Object Orientation and Fortran 2002: Part I", Fortran Forum, Vol. 16, No. 3
>(December 1997).
>
>"Object Orientation and Fortran 2002: Part II", Fortran Forum, Vol 18, No. 1
>(April 1999).
>
>Part II is self-contained, and describes most of the object-oriented
features.
>Part I looks at some of the simpler features in greater detail (and with a
>slightly different syntax from the current draft).
>
>Cheers,
>--
>...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
>                           ([log in to unmask])
>
>_____________________________________________________________________
>This message has been checked for all known viruses by Star Internet
delivered
>through the MessageLabs Virus Control Centre. For further information visit
>http://www.star.net.uk/stats.asp
>