anything marked as "returning" void?
Some languages (eg. pascal) distinguish between functions that return
something and procedures that don't. Traditionally in mathematics a
function doesn't have side effects as there is nothing to have side
effects on. I think the aim of the Pascal function/procedure
distinction was that functions should be without side effects (ie.
don't modify the program state or do i/o). Whilst procedures modified
the environment and/or do i/o. But I don't believe Pascal enforces
this distinction. It's supposed to be a lot easier to prove things
about programs that lack side effects. But practically its hard to
write useful programs that lack side effects. Take a look at a
functional language (that doesn't just mean "has functions") or
prolog.
Algol recognizes the reserved word procedure, and a procedure may
return a value.
I can't remember whether Fortran IV had subroutines that returned a
value (IIRC they couldn't).
In Algol the difference is obvious to the compiler. So there was no
linguistic need to use different reserved words
to make that clear to the compiler. Pascal makes the difference
because it specifies the object type at the end of a declaration.
Algol Pascal C
INTEGER PROCEDURE SUM(..); function sum(..):integer; int
sum(..)
PROCEDURE DOTHIS(..); procedure dothis(..); void
dothis(..)
INTEGER GETAL; var getal:int; int
getal;
I guess that the decision to put the type of a variable at the end of
the declaration in Pascal forced the need
to alert the compiler what was coming. C followed Algol and put the
type in fornt of the variable list. Which is
IMHO a more natural way of doing things.
Other than that there is no other difference. It is perfectly alright
to perform IO in functions. And procedures
can return fascinating results via parameters, e.g. Jensen's device.
Basically the motto of Algol60 explains it all: Was sich überhaupt
sagen lässt, lässt sich klar sagen (Wittgenstein).
Which probably explains why Algol remains my favourite language ;-)
Hans