Neat. I have sometimes wished to write a Fortran procedure that can take any number of arguments of any type. The built-in print
statement has this feature. How @urbanjost does it is to declare many class(*),intent(in),optional
arguments, as shown in his code
pure function msg_scalar(generic0, generic1, generic2, generic3, generic4, generic5, generic6, generic7, generic8, generic9, &
& generica, genericb, genericc, genericd, generice, genericf, genericg, generich, generici, genericj, &
& sep)
implicit none
class(*),intent(in),optional :: generic0, generic1, generic2, generic3, generic4
class(*),intent(in),optional :: generic5, generic6, generic7, generic8, generic9
...
His function takes up to 20 arguments, which is more than needed in almost all cases, but a code could be written to generate source code for a function that takes N > 20 arguments. So with automatic code generation you can get in Fortran some of the flexibility you have in Python.