[J3] [SC22WG5.6608] RE: RE: [ukfortran] intent(in) and value
Klemm, Michael
Michael.Klemm at amd.com
Thu Sep 19 01:33:50 UTC 2024
Hi folks,
Thanks for the clarification!
One more thing: Is it then sensible to have a variable have the attributes VALUE and INTENT(IN) at the same time?
From: Jeff Hammond <jehammond at nvidia.com>
Sent: Wednesday, September 18, 2024 7:29 PM
To: General J3 interest list <j3 at mailman.j3-fortran.org>; 'WG5' <sc22wg5 at open-std.org>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: Re: [J3] [SC22WG5.6606] RE: [ukfortran] intent(in) and value
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Thanks. This is useful context and a helpful explanation.
Jeff
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org>
Date: Wednesday, 18. September 2024 at 12.20
To: 'WG5' <sc22wg5 at open-std.org>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: [J3] [SC22WG5.6606] RE: [ukfortran] intent(in) and value
External email: Use caution opening links or attachments
Hi Jeff,
It is called "unspecified INTENT" not "default INTENT". That is because it is not a default, it is that it is not specified. (ASIDE: I don't think we use the phrase in the standard itself, but we do when talking about it.)
R828 by itself does not define the INTENT attribute, it defines some syntax - and that is the syntax for specified intent (it's even called "intent-spec". The whole of 8.5.10 defines the INTENT attribute, and indeed, there is a paragraph about unspecified intent.
INTENT(INOUT) is very different indeed from unspecified intent. In particular, INOUT requires that the actual argument be a definable variable. There is no such requirement for unspecified intent. With unspecified intent you simply have to get it right, viz not reference the dummy argument unless it is defined, and not define the dummy argument unless it is definable. This is the world before the invention of INTENT.
To summarise: with no intent-spec, the intent is not "INOUT", or "INOUT except stuff", it is "unspecified", and has the same capabilities and limitations that it had before Fortran 90.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: owner-sc22wg5 at open-std.org <owner-sc22wg5 at open-std.org> On Behalf Of Jeff Hammond
Sent: Wednesday, September 18, 2024 4:12 PM
To: WG5 <sc22wg5 at open-std.org>
Subject: [ukfortran] [SC22WG5.6604] intent(in) and value
8.5.10 R828 says that INTENT is IN, OUT or INOUT.
8.5.19 C868 says that VALUE cannot be INTENT(OUT) or INTENT(INOUT)
Should I understand that dummy arguments without an INTENT do not have an implicit intent corresponding to any of the explicit INTENT types? I have always assumed that the default INTENT was INOUT, but that cannot be true since that would conflict with VALUE in the example below. It seems the default INTENT is "INOUT, unless VALUE, in which case it's IN-but-also-assignable".
subroutine foo(a,b)
implicit none
integer, value, intent(in) :: a
integer, value :: b
! integer, value, intent(inout) :: c ! not allowed
! integer, value, intent(out) :: d ! not allowed
! a = 21 ! can't assign because intent(in)
b = 23 ! can assign
end subroutine foo
Thanks
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20240919/8e41cef8/attachment-0003.htm>
More information about the J3
mailing list