`block` syntax and my confusion

This would irritate me more

integer :: n, m, p

do integer :: i = 1, n
  do integer :: j = 1, m
     do integer :: k = 1, p
        ! ...
     end do
  end do
end do

than this

integer :: i, j, k, n, m, p

do i = 1, n
  do j = 1, m
     do k = 1, p
        ! ...
     end do
  end do
end do

If I remember Steve’s talk from FortranCon correctly, Fortran 202x does plan to introduce integer declaration in implicit do loops:

integer :: a(5)

a = [(i, integer :: i = 1, 5)]

I find this quite attractive.

Ultimately, I prefer to just accept that C and Fortran are different languages which require different coding practices. If not we can start asking ourselves the reason why can’t integer be abbreviated as int, why does subroutine need to be longer than void, why do we even need the function statement when the type would do, and so forth…

4 Likes