(j3.2006) Comment concerning TEAM_TYPE

Malcolm Cohen malcolm
Tue Oct 8 20:15:34 EDT 2013


I wrote:
> If everything in TEAM_TYPE is default-initialised, one does not need
> the constructor at all.

Van disagreed:
>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.

Yes it can.

  type,extends(team_type) :: team_kludge
  end type
  type(team_kludge),parameter :: kludge = team_kludge()
  type(team_type),parameter :: null_team = kludge%team_type

and then

  type(t) :: t_var = t(null_team,my_type(42))

(rest of discussion snipped as being moot given the counterexample).

One might reasonably say that the kludge above is ugly, but I never claimed it 
would be elegant!  It seems to conform to the rules proposed in N1983 though. 
Whether we intended to allow named constants of type TEAM_TYPE I cannot say...

Cheers,
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo. 




More information about the J3 mailing list