j3-fortran / fortran_proposals

Proposals for the Fortran Standard Committee
178 stars 15 forks source link

Allow argument declarations of the same name as the parent non-recursive function or subroutine #204

Open acikek opened 3 years ago

acikek commented 3 years ago

This seems like an oversight. Currently, this is considered a syntax error. Since, in non-recursive functions or subroutines, itself cannot be called, there is no reason to disallow this. Here is an example:

! Non-recursive
subroutine example(example) ! Syntax error
  implicit none
  integer :: example
end subroutine example
klausler commented 3 years ago
subroutine example(example)
  integer :: example
  call foo(example)
end subroutine

Which example gets passed?

acikek commented 3 years ago

Looks like that's an oversight on my part. Nonetheless, the integer variable. If you were going to pass the subroutine as an argument, you wouldn't have one of the arguments for itself be named the same. As far as I'm aware, many languages allow this scope redefinition.

acikek commented 3 years ago

I don't like the idea anymore after you brought that to my attention, although I'd like this issue to stay open in case there's any more comments to address.