[J3] Default values for optional arguments

William Clodius w.clodius at icloud.com
Thu Jan 21 02:50:46 UTC 2021

To me there are two possible argument passing attributes for default arguments: INTENT(IN) or VALUE. INTENT(IN) arguments cannot have the ALLOCATABLE attribute and with the absent argument the default would be a constant in the environment of the call site and the argument passing . With the VALUE attribute an absent argument with a default value could have the interpretation of an automatic local variable with automatic initialization.

> On Jan 20, 2021, at 3:00 PM, Van Snyder via J3 <j3 at mailman.j3-fortran.org> wrote:
> 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/66ce701c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1619 bytes
Desc: not available
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210120/66ce701c/attachment.bin>

More information about the J3 mailing list