Malcolm said:
The question is whether to use an existing word or coin a new one.
... or whether not to bother at all, since the distinction
between "method" and "section" is meaningless in C.
For my purposes
int foo(void)
and
void foo(int *ret)
don't have any really important differences. From a compiler writer's
point of view, of course, it is important that if(foo()) is legal whilst
if(foo(&x)) is not.
Not a special case, nor an essential difference between a
void-valued function and an other-valued one. For example,
consider that
struct bar baz(void);
if (baz()) ...
.... is also invalid, even though baz returns a value. It is
not the void-ness or void-not of a function that determines
whether its returned value can be used in an `if' (or assigned
to a variable, or whatever), but the type of the returned value.
A void-valued function is illegal in some contexts; a struct-
valued function is illegal in some contexts; an int-valued
function is illegal in some contexts. It's the type that makes
the difference, not the void-ness.
Similalry from an algorithms point of view we are not too interested in
whether a function receives its parameters as arguements or in globals.
Under the bonnet a lot of compilers implement globals with a pointer
that is in scope for every function, anyway.
I've never encountered one that does so, no, not even once --
but I've encountered somewhat fewer than all compilers. No doubt
you're right, and the world is full of "a lot" of weird compilers.
(It would go some way towards explaining your ideas about C.)
So the important difference is between code which calculates something,
and code which does something. You could stretch the point by saying
that flow control is a third class of code, but that can probably be
ignored.
Why is this difference "important?" Why is it even "the least
bit important?" It's a pointless digression in the book, that's
all. You should consider removing it from the second printing.
"Function" is the accepted mathematical term for a mapping of input to
output, which is what a calculation is, so I can use it. "Procedure"
isn't firmed up, largely because the word is used in so many different
ways. However it has the English meaning of a "series of actions". Given
that I'd decided not to coin my own words, procedure seems the best
choice for a subroutine that isn't only a function. Procedures can call
functions, but functions cannot call procedures.
Since "procedure isn't firmed up," you can say whatever you
like about it without advancing the discussion.
(Your text offers strlen() as an example of a "function," but
by your definition it isn't one, or at any rate needn't be one.)
That's my use. An "action" is IO, if you think about it. Everything else
is just shuffling bits about in memory.
http://en.wikipedia.org/wiki/Begging_the_question