> I was a bit surprised to find that our f90 compiler was not happy with the
> following:
>
> function test
> integer :: test
>
> I was puzzled why it is necessary to have instead:
>
> function test()
> integer :: test
>
> I was writting a module where I wanted all variables private and access
> functions to return the value. Hence functions with no arguments.
>
> The () on the function statement seem completely redundant so why have
> them? p112 on fortran90/95 explained appears to show them as required so
> it's obviously part of the standard.
They have always been required (by the standard). They are not required
for subroutines.
If you believe that all functions should be pure, then it makes little
sense to have a function without arguments, since it would always return
the same value. Why not use a subroutine?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|