j3-fortran / fortran_proposals

Proposals for the Fortran Standard Committee
178 stars 15 forks source link

SPLIT intrinsic #187

Open certik opened 3 years ago

certik commented 3 years ago

US03 - SPLIT string intrinsic

certik commented 3 years ago

This is a great candidate for an stdlib implementation: https://github.com/fortran-lang/stdlib/issues/241

milancurcic commented 3 years ago

Definition of SPLIT is in 16.9.194 of 20-007.

milancurcic commented 3 years ago

I put an implementation here: https://github.com/milancurcic/fortran202x_split. I will request feedback in the stdlib issue.

milancurcic commented 3 years ago

We discussed the split API on a call on Tuesday. You can watch the recording here.

On the call we came to an overall tentative agreement that the 3rd form of split may be not appropriate or intuitive to be part of the split functionality. As a reminder, the 3 forms of split, after 20-007 and 20-139 are:

  1. SPLIT (STRING, SET, TOKENS [, SEPARATOR])
  2. SPLIT (STRING, SET, FIRST, LAST)
  3. SPLIT (STRING, SET, POS [, BACK])

While we found that the first two forms are useful and meaningful for split, we also found that the 3rd form is not appropriate because it doesn't actually do any splitting. Instead, it does "finding", which is more akin to the intrinsic index. Bundling the 3rd form of the currently approved split with the other two may thus be confusing to Fortran programmers.

We decided to write a proposal against exclude the 3rd form in the split intrinsic for F202X. I have agreed to take a lead on it. I plan to have a PR draft in this repo by early December, so it can be discussed ahead of time both here and on the J3 mailing list and/or forum well ahead of time.