Fortran-202X-Proposals icon indicating copy to clipboard operation
Fortran-202X-Proposals copied to clipboard

Proposal: Default value for allocatable derived type component

Open jacobwilliams opened this issue 6 years ago • 0 comments

Allow for the default state of allocatable variables to be allocated with a specified value:

type my_type
  integer :: i = 1  ! this has "always" been possible
  character(len=:),allocatable :: str = 'default'  ! this is not currently possible
end type my_type

This would also enable parameters:

  type(my_type),parameter :: t1 = my_type(1,'option 1')
  type(my_type),parameter :: t2 = my_type(2,'option 2')

jacobwilliams avatar Jul 05 '17 14:07 jacobwilliams