From off list:
> On 29/03/21 11:14, Ian Harvey wrote:
>> My view... in this particular example, the use statement is not
>> required. Its appearance is permitted, though pointless.
>>
>> If the module procedure subprogram referenced identifiers from the
>> `baz_m` module (such as a reference to `baz_t` to declare a local
>> variable), then the use statement would be required to be repeated
>> in the subprogram.
>>
>> The interface body for the procedure is a separate scoping unit to
>> the subprogram for the procedure. The procedure declared by the
>> subprogram has its *interface* declared by the interface body, not
>> other stuff. There is a limited list of things that comprise the
>> interface of a procedure - which use statements might be present in
>> the subprogram defining the procedure is not one of those things.
>>
>
> My understanding is that the interface is basically a procedure type
> declaration.
>
> In the module procedure body there is no need repeat the arguments
> type declarations has only the procedure name would suffice (as in
> any type declaration).
Fortran does not have the concept of "procedure type".
The interface of a procedure "consists of its name, binding label,
generic identifiers, characteristics, and the names of its dummy
arguments" (F2018 15.4.1). The characteristics of a procedure in turn
include the characteristics of its dummy arguments (see 15.3), plus a
specific list of other things. The characteristics of a dummy argument
(plus its name) include the things that would be covered by declarations
for the dummy arguments.
The list of things that are considered part of the interface of a
procedure is quite specific. That list does not include "this module
happened to be referenced via a use statement as part of specifying the
interface". (Which is good - we don't want to care how a particular
identifier was introduced into a scoping unit - at the end of the day it
is the meaning of the interface that is important, not its syntax.)
> The problem is that, at least in some processors, there is indeed
> other stuff depending on the use statement, mostly due to the OOP
> stuff.
What other stuff?
> That is why I was expecting to be some standard clause requiring the
> use statement repetition.
You need to "repeat" the use statement if you reference things from the
module inside the subprogram. (You are not really repeating the
statement - because the subprogram is a different scoping unit.)
>> (I suspect there is missing normative text in the section of the
>> standard on "Scope, Association and Definition" around the scope of
>> the identifiers for things like dummy variables and function
>> results that are declared in the interface body, being extended to
>> include the scoping unit of the subprogram. If this normative text
>> was present, things might be clearer.
>>
>
> IMHO it does not make sense to require that procedure types must
> include any of the used module(s) information.
>
> And, on further reflection, I would say that it should be sufficient
> to require that any extra type information must "travel" in the type
> definition itself.
I don't follow your point.
>> I also suspect there is missing normative text around the
>> determination of derived types - a type declaration repeated
>> between the interface body and the subprogram would appear to be
>> defining a separate type.)
>>
>
> There should be some wording in the standard that demands that the
> processor handles any extra type information (has if) it is included
> in the type definition itself, not in the module.
I presume you mean interface definition. The standard does not say what
you want. What you ask for would break code that follows what it says
currently, in perhaps more obscure circumstances.
The standard has explicit text that goes the other way, in part. "The
specification part of an interface body may specify attributes or define
values for data entities that do not determine [the?] characteristics of
a procedure. Such specifications *have* *no* *effect*." (Emphasis mine).
> This way there would be no need to repeat the use statement, as all
> necessary type information would be available in the procedure
> interface itself.
>
> Thank you very much.
>
> Best regards, José Rui