As I have explained above, I will stress a few aspects of the desired facility including its semantics before diving deep into the syntax. But say for the sake of discussion the new type is named string
. Then
-
This new type shall be an intrinsic one and the standard semantics on intrinsic types shall apply to
string
starting with it not being an extensible type. -
This intrinsic type shall thus be declarable in any scope where other intrinsic types such as integer can be declared. Thus no
USE
statement shall be needed to import the type into a scope. -
string
type shall be as though it has a private component of the intrinsic typecharacter
, -
The processor shall support at least two KINDs of this `string| type: one KIND as though the component mentioned in 2 above is of default character; the second KIND as though the character component is of ISO 10646 set.
-
A convenient means to define a variable of this type using character literal constants shall be available.
-
A convenient means to construct an array of
string
type with character strings of same or different lengths shall be available, possibly like so:
string :: pets(3)
pets = [ string :: "dog", "pony", "turtle" ]
- The same means to access sections of character data as applicable to character intrinsic type including with arrays of character type shall be available to string e.g.,
string :: language
language = "Fortran"
print *, language(1:3) ! outputs "For"
string :: pets(3)
pets = [ string :: "dog", "pony", "turtle" ]
print *, pets(1)(1:2) ! outputs "do"
- Methods to operate on the character data of string data shall also be available as though they are type-bound. The list of methods shall be identified based on feedback from the Community and reviewed and developed in a workflow similar to Fortran
stdlib
. However the list shall include a method namedinsert
to introduce a string of provided character(s) at the specified positionpos
e.g.,
string dilemma
dilemma = "to be the question"
call dilemma%insert( pos=7, chars="or not to be is" )
I have a longer list of additional requirements based on use cases involving library solutions that have been consumed for such a type and which I can provide over time.
However I just wanted to get the ball rolling where you and the readers to review the above 8 items and see how it’s received, what are the comments and the feedback, what you think is the feasibility for implementation in LFortran
.
Thanks,