webpage icon indicating copy to clipboard operation
webpage copied to clipboard

Derived types section -- have more discussion of F95-level concepts

Open Beliavsky opened this issue 4 years ago • 0 comments

I understand that the Fortran-lang tutorial is short and selective in what it covers. However, reading the Derived types section, I think there is a jump in level starting with "Derived types in detail", which covers features from Fortran 2003+ (bind, extends, abstract) that I consider advanced. I would first discuss basic usage of derived types that existed in Fortran 95, such as (1) printing a derived type (2) using derived types as procedure arguments and function results (3) using arrays of derived types. In particular, the simple way that you can refer to the components of an array of derived types is a strength of Fortran. For example, given

type, public :: date_mdy 
   integer :: month, day, year
end type date_mdy
type(date_mdy) :: dates(100)

you can refer to all the months, days, and years with dates%month, dates%day, dates%year.

After this basic usage of derived types one could discuss operator overloading. Given a date derived type it is natural to define operators such as == and >. Examples could be given of how to do this.

If desired, I could write a section with a module defining a date derived type and a program using it.

Beliavsky avatar May 25 '21 00:05 Beliavsky