Description
Several PRs (#201, #221, #224) wishes to introduce derived types into stdlib. We need a name convention for them. The conventions I have met in Fortran code so far, are the following ones:
-
Singular noun, such as
type(os_error)
,type(bitfield)
. Pro: compatible with Fortrans naming convention (e.g.type(c_ptr)
). Con: You reserve a name, which would be also very natural for an instance variable, e.g.type(bitfield) :: bitfield
does not work. -
Plural noun, such as
type(os_errors)
andtype(bitfields)
as suggested for example in API for a bitset data type #221. Pro: You can give the corresponding singular name to the instance variable:type(bitfields) :: bitfield
. Con: All languages I know use singular for type/class names, so it may feel strange an unnatural for stdlib-newcomers. -
Singular noun with a
_t
suffix, such as:type(os_error_t)
,type(bitfield_t)
. Pro: You can use the noun without the suffix as instance variable, e.g.type(bitfield_t) :: bitfield
. Con: The extra_t
is redundant.
I am tending towards option 1. with the additional restriction, that derived type should always contain at least two nouns (connected by underscores). Then, the corresponding variable instance name could be still exactly the same, but without the connecting underscore, e.g. type(bit_field) :: bitfield
or type(os_error) :: oserror
.
Any opinions on this?