Glenn Carver wrote:
> 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.
> No big deal, I'm just curious.
Malcolm has already explained why the () are necessary on the declaration.
They're necessary at the reference, in the case it's an actual argument,
to distinguish between the function and the result of invoking it. Actual
arguments are <expressions>. Rather than make a bizarre exception, the ()
are required in all expressions, not just in the ones that aren't actual
arguments. In Fortran 200x, in the case that a function is the RHS
of a pointer assignment, and the LHS is a procedure pointer, the presence
or absence of the () will indicate whether to use the function or the
result of invoking it. In the latter case, the result is required to
be a procedure pointer.
--
What fraction of Americans believe | Van Snyder
Wrestling is real and NASA is fake? | [log in to unmask]
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Dan Goldin, Bill Clinton, the Pope, or anybody else.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|