[J3] [EXTERNAL] Re: Default values for optional arguments

Thomas König tk at tkoenig.net
Fri Jan 22 17:04:44 UTC 2021


Hi Vipul,

 > On Fri, Jan 22, 2021 at 9:18 AM Clune, Thomas L. (GSFC-6101) 
<thomas.l.clune at nasa.gov <mailto:thomas.l.clune at nasa.gov>> wrote:
 >
 >     ..
 >
 >     But again the real problem arises when there are multiple such dummy
 >     arguments.   Lots of things look tolerable when there is only 
one.   ..
 >
 >
 > TL;DR version:
 > 1. Original note, as worded, was about possible errors with the use 
of a local variable, not multiple optional arguments.

I didn't include that, but yes, it is a valid concern as well.

Some of the methods that have been raised such as calling extra
subroutines with the defaults filled do not work for cases
where the types of the default arguments agree, such as

   subroutine foo(a,b,c)
     real, intent(in), dimension(:) :: a
     integer, intent(in), optional :: b, c

...

   Using

   call foo(a,c=42)

is different

   call foo(a,b=42)

but if just

    call foo_generic(a,42)

is used, this is ambiguous, and you can't use argument names
to distinguish between generics (now THAT would be syntactic
cyanide :-)

 > 2. Even with multiple optional arguments, alternate options in the 
Fortran standard can prove cost-effective for all involved.
 >
 > Note the original email by Thomas Koning

König (or Koenig, if you will).

 > The point will be that as codes get more modernized and make use of 
newer facilities beyond the *intrinsic* types, any additional work now 
in the Fortran standard to do anything with DEFAULT values of OPTIONAL 
dummy arguments will either fall terribly short of the needs or force 
the standard on to a slippery slope of more complicated semantics (and 
syntax) to support the scenarios.

I currently fail to see where exactly the slippery slope is leading
and what is actually so bad.  Could you maybe elaborate?

Best regards

     Thomas



More information about the J3 mailing list