[J3] [SC22WG5.6606] RE: [ukfortran] intent(in) and value

Malcolm Cohen malcolm at nag-j.co.jp
Wed Sep 18 09:13:51 UTC 2024


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/20240918/a62eadf7/attachment-0001.htm>


More information about the J3 mailing list