Skip to content

Commit 86c0efe

Browse files
committed
addition of present()
1 parent 62282eb commit 86c0efe

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

proposals/default_optional_arguments/proposal.txt

+20-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,26 @@ This addition to the language would not break any existing standard
102102
conforming Fortran program, and thus preserves Fortran's backward
103103
compatibility.
104104

105-
4. Further discussion
105+
4. Related intrinsic functions
106+
107+
4.1 present()
108+
109+
When the optional dummy argument has an initializer, the function
110+
present() will return .true., even if the actual argument is not passed
111+
by the caller.
112+
113+
Example:
114+
115+
real function foo(a, b)
116+
real, intent(in), optional :: a
117+
real, intent(in), optional :: b = 0
118+
print*, present(a) !.true. if an actual argument is provided
119+
!by the caller, .false. otherwise
120+
print*, present(b) !always .true. due to the initializer
121+
end function foo
122+
123+
124+
5. Further discussion
106125

107126
Online discussion that led to this proposal can be found at
108127
https://github.com/j3-fortran/fortran_proposals/issue/22.

0 commit comments

Comments
 (0)