F2003: pass disallowed for procedure pointer components?
- From: Reinhold Bader <Bader@xxxxxx>
- Date: Thu, 28 Dec 2006 17:09:57 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
In a discussion with Andy Vaught concerning procedure pointer components the issues
described in the following came up:
Is the following module
module foo
implicit none
private
type, public :: tt
double precision :: a, b
procedure(fun), pointer, pass :: f
end type
abstract interface
subroutine fun(this, x)
import :: tt
type (tt), intent(inout) :: this
double precision, intent(in) :: x
end subroutine
end interface
end module
standard conforming? Consulting the standard appears to indicate that this is
not the case, since in 12.3.2.3 we have:
24 C1212 (R1215) The name shall be the name of an abstract interface or of a procedure that has an
25 explicit interface. If name is declared by a procedure-declaration-stmt it shall be previously
26 declared. If name denotes an intrinsic procedure it shall be one that is listed in 13.6 and not
27 marked with a bullet (�).
provided the second sentence of C1212 can be interpreted as having the same meaning as
"A /name/ referenced by a /procedure-declaration-stmt/ shall be previously declared."
Going further, it is also not possible to have
module foo
implicit none
private
abstract interface
subroutine fun(this, x)
import :: tt
type (tt), intent(inout) :: this
double precision, intent(in) :: x
end subroutine
end interface
type, public :: tt
double precision :: a, b
procedure(fun), pointer, pass :: f
end type
end module
since in 12.3.2.1 we have (p260:3-7):
9 The IMPORT statement specifies that the named entities from the host scoping unit are accessible in
10 the interface body by host association. An entity that is imported in this manner and is defined in the
11 host scoping unit shall be explicitly declared prior to the interface body. The name of an entity made
12 accessible by an IMPORT statement shall not appear in any of the contexts described in 16.4.1.3 that
13 cause the host entity of that name to be inaccessible.
All this seems to indicate that it is not possible to have a passed object dummy argument for a procedure
pointer component notwithstanding the fact that
(i) 4.5.3.3 explicitly mentions the passed object dummy argument as being applicable also for procedure
pointer components
(ii) 12.4.1.1 (with the correction F03/0043 from 05-016) confirms this.
Finally, if the second sentence of C1212 simply was misunderstood by me, the example is probably still
non-conforming due to C453 in 4.5.3.3, according to which the passed object dummy must be polymorphic, i. e.
class(tt), intent(in) :: this
Why was this deemed necessary also for procedure pointer components?
References used:
http://j3-fortran.org/doc/2003_Committee_Draft/04-007.pdf
http://j3-fortran.org/doc/standing/016%20Completed%20Fortran%202003%20Interpretations/05-016.txt
Regards
Reinhold Bader
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFFk+xVzwkB8vcRvCoRAmkbAJ0X3C5PVTwA0AJsTiAeqE2fXxPUOwCeOvgZ
9MXxLRP0RIjHBT8Sf68rGKQ=
=CLcc
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: F2003: pass disallowed for procedure pointer components?
- From: Richard E Maine
- Re: F2003: pass disallowed for procedure pointer components?
- Prev by Date: Re: Dimension attribute based on host-associated variable - bug in Intel Fortran
- Next by Date: Re: internal I/O to substring
- Previous by thread: Write A, left justified, howto?
- Next by thread: Re: F2003: pass disallowed for procedure pointer components?
- Index(es):