Re: Allow interspersed named and positional arguments?



Beliavsky wrote:
In Fortran, all arguments in a call after the first named argument
must also be named, so that

subroutine foo(x1,x2,x3,x4,x5,x6)
! assume all arguments optional

...

call foo(a1,x3=a3,a4,x5=a5,x6)

is not allowed.

(I'll assume that's true... I didn't check the std)

I wish it were allowed,

Why?

with the interpretation that positional
arguments after named arguments are presumed to be the successive
arguments in the callee, until the next named argument appears, so
that the code above would be equivalent to

call foo(a1,x3=a3,x4=a4,x5=a5,x6=a6)

Then write it that way.

Making this change would not provide substantial new functionality,
but I think it would be convenient, and it does not seem too difficult
for compiler writers to implement.

I have no idea as to the ease or difficulty of implementing your suggestion (although I'd bet it's not as simple as it may seem :o), but even you state "[m]aking this change would not provide substantial new functionality".

So .... why do it? Is it *that* inconvenient to write "x4=a4" as opposed to just "a4"?

cheers,

paulv
.



Relevant Pages

  • Re: find function (i.e. not subroutine) possible without memory leak?
    ... In the mentioned subroutine, do I have to check if indices ... is allocated, deallocate it if this is the case, and then allocate it again. ... > Watl wrote: ... > 2003, which includes such functionality. ...
    (comp.lang.fortran)
  • Encapsulate
    ... Following are the reply by Paulv at the post "Many small programs vs. ... When you subsequently discover a bug in one of your ... subroutine Run_SetAlgorithmParameters ... end module modA ...
    (comp.lang.fortran)
  • Re: Encapsulate
    ... Following are the reply by Paulv at the post "Many small programs vs. ... When you subsequently discover a bug in one of your ... subroutine Run_SetAlgorithmParameters ... end module modA ...
    (comp.lang.fortran)
  • Allow interspersed named and positional arguments?
    ... In Fortran, all arguments in a call after the first named argument ... subroutine foo ... Making this change would not provide substantial new functionality, ... for compiler writers to implement. ...
    (comp.lang.fortran)
  • Re: using optional arguments not present (bug)
    ... Beliavsky wrote: ... At the beginning of a subroutine I define a local ... I wish compilers would warn about such usage at ... derived type argument intents are OUT when I *clearly* meant IN OUT. ...
    (comp.lang.fortran)