This is, eh, wrong. The same holds in Fortran where you need not declare
functions anywhere, or only the return type when it is not the default.
Fortran is typically used for large MLOC programs and there is *no*
performance penalty.
In classic FORTRAN, or the (nearly) equivalent subset of modern
Fortran. Where, as you note below, all arguments to all routines are
passed the same way -- usually, and canonically, all by reference,
although value-return was also permitted and sometimes used at least
for certain types like scalar integers and floats.
Except if you use the same name as an 'instrinsic' (= builtin =
standard) routine, in which case you need to declare it EXTERNAL even
if you don't (need to) declare the type.
The reason is that giving declarations gives the compiler the option to
check parameter types and act accordingly when they do not match the
types of the actual parameters supplied. In Python all types of
parameters are passed the same way to a function, including type
information.
In modern Fortran (>=90) there are new options for parameters (which
Fortran calls dummy arguments, using the term parameter for something
else) which require the called routine to have an 'explicit interface'
visible to the caller. This is semantically equivalent to a prototype
in C (or declaration in C++), but a bit confusingly is not always
actually written. There are three choices:
- Fortran (now) allows 'contained' = nested (to one level) routines.
Such a contained routine necessarily appears in the same source unit
(after preprocessing if applicable) as the caller and its 'explicit'
interface is (implicitly!) available.
- Similarly it provides 'modules' similar to Java or Ada packages,
which can store data and (selectively) export routines (and data
items) to client code. Such a module is separately compiled and
produces, in addition to object code for linking and execution,
interface info, typically in an x.mod file, used to compile clients.
- Finally, for separately compiled (including third-party) code to
which neither of these applies, you write an actual description called
an interface block, similar to an actual Fortran subprogram header and
not too unlike a K&R1C function definition header.
- David.Thompson1 at worldnet.att.net