(j3.2006) separate module procedures question

Reinhold Bader Reinhold.Bader
Tue Dec 22 12:55:25 EST 2009


Hello Bill,

Bill Long schrieb:
> We got an interesting variant on separate module procedures, which can
> be reduced to this test case:
> 
> module modu
> 
>   interface
>     module function rst(x)                 ! okay
>       real :: x
>     end function rst
> 
>     module subroutine rst_1(x)             ! okay
>       real :: x
>     end subroutine rst_1
>   end interface
> 
> contains
> 
>   function rst(x)                          ! Error -> Needs module
> prefix  ??
>   real :: x
>   rst = 6*3.14
>   end function
> 
>   subroutine rst_1(x)                      ! Error -> Needs module
> prefix ??
>   real :: x
>   end subroutine
> end module modu
> 
> 
> it is pretty clear what the user intended here (an intermediate step in
> converting to using submodules), and the compiler can easily generate
> unambiguous code.  However, it appears to be illegal.

I agree.

> 
> The rules are that an interface body that begins 'module
> subroutine...' or 'module function...' specifies the interface for a
> "separate module procedure" [281:20-21].  A "separate module procedure"
> is a procedure whose definition begins with  'module subroutine...',
> 'module function...', or 'module procedure...'. [309:21-23].
> 
> I could see three candidate answers for an interp question [Was this
> intended to be conforming?]  for this case:
> 
> 1)  The definition of "separate module procedure" should have made the
> MODULE optional if the procedure is defined in the same module as its
> corresponding separate interface body.  If that were the case, the code
> is fine, and clear as to what is intended.
> 
> 2) The defined procedures (which are not separate module procedures) are
> different from the ones (which are separate module procedures) specified
> by the interfaces, in which case they effectively cannot be referenced.
> You have essentially specified two different procedures that have the
> same name.
> I think this would be confusing for users.

To assure this cannot happen it might be appropriate to add "interfaces of separate
module procedures" to class (1) in 16.3.1 para 1.

> 
> 3) The program has a syntax error.  The procedure definitions require
> the MODULE prefix in their initial lines.
> 
> 
> Answer (3) is simplest, but did we ever consider option (1)?
> 
> 
> Cheers,
> Bill
> 
> 
> 
> 

Regards
Reinhold



More information about the J3 mailing list