I use a default function in my codes, similar to optval in stdlib, that accepts two arguments, the second optional, and returns the second argument if present, otherwise the first. So I’d write the code above as
call sub(a,b,c,default(merge(epsilon(x),spacing(x),x<1),d))
Since epsilon(x) and spacing(x) do not require computation, this is fine. When the default values of an expression do require considerable computation, then the wordy if block is required to avoid redundant computation.
In general, Fortran does not have lazy evaluation. Would it be possible to have an intrinsic function, say lazy_merge(x,y,true_or_false), that breaks this pattern and for which the compiler evaluates the third argument first and then evaluates the first or second as appropriate? This would simplify a lot of code. I guess this is just different syntax from what is being proposed?
P.S. Why does the committee use all upper case in code examples?