[J3] Default values for optional arguments

Van Snyder van.snyder at sbcglobal.net
Wed Jan 20 22:00:28 UTC 2021


On Wed, 2021-01-20 at 12:28 +0000, Bill Long via J3 wrote:
> There was a proposal for default optional argument values for F202X
> that failed for the reason given above.   Something like
> 
> integer, intent(in), optional, default(42) :: b
> 
> might work.If this were to work, then subsequent tests for Present(b)
> would have to return true to avoid conflicts with existing code.
> There might be other side effects that are undesirable. 

It's not obvious how this would work if the optional argument is an
allocatable array.

The obvious interpretation of an absent optional argument with a
default value is that it becomes an automatic local variable, with
automatic initialization.

People have been asking for automatic initialization, i.e., that
doesn't imply SAVE, for decades.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210120/66bd553e/attachment.htm>


More information about the J3 mailing list