News for hackers. Stuff that matters.
Re:Learning the oldest programming language (2024) by sampo on Wednesday December 17, 2025 @11:53PM (#46308997)
> Suppose you pass a parameter, N, and you also would like to pass a tensor, and you would like to specify the tensor's shape (N, N).

You can do that, and it might be cleaner and less lines of code that way.

But you don't necessarily need to pass the array dimensions as a parameter, as you can call `size` or `shape` to query it inside your function.

    program main
      implicit none
    
      real :: a(2, 2) = reshape([1., 2., 3., 4.], [2, 2])
    
      call print_array(a)
    
    contains
    
      subroutine print_array(a)
        real, intent(in) :: a(:, :)
        integer :: n, m, i, j
    
        n = size(a, 1) ; m = size(a, 2)
        write(*, '("array dimensions:", 2i3)') [n, m]
        do i = 1, n
          do j = 1, m
            write(*, '(f6.1, 1x)', advance='no') a(i, j)
          end do
          print *
        end do
      end subroutine
    
    end program
Re:Learning the oldest programming language (2024) by thatjoeoverthr on Thursday December 18, 2025 @05:27AM (#46310981)
True! I just wanted to highlight it. (I had to do this at an interface because the ABI doesn’t pass the shape.)