(j3.2006) Comment concerning TEAM_TYPE

Van Snyder Van.Snyder
Tue Oct 8 14:47:20 EDT 2013

On Tue, 2013-10-08 at 13:56 +0900, Malcolm Cohen wrote:
> If everything in TEAM_TYPE is default-initialised, one does not need
> the constructor at all.


Suppose one has a type

  type :: T
    type(team_type) :: MyTeam
    type(my_type) :: MyStuff
  end type T

and one wants to create an initialized variable

  type(t) :: T_var = t(team_type(),my_type(42))

That cannot be done without access to the team_type() constructor.

Without the team_type() constructor one cannot instead write

  type :: T
    type(team_type) :: MyTeam = team_type()
    type(my_type) :: MyStuff
  end type T

so that one could write

  type(t) :: T_var = t(my_type(42))

thereby avoiding the necessity to reference team_type() in the
constructor for t().  The problem doesn't go away; it just moves to a
different place.

If team_type is not to have a constructor, we should perhaps make the
rules for constructors say that one doesn't need a to put a value for a
component in a constructor if the component is of a derived type for
which all direct components have default initialization.  But that
requires that all components of team_type have default initialization,
which makes the constructor available -- unless we specify that it

More information about the J3 mailing list