Yasuki Arasaki wrote:
> I usually use FUNCTIONSs only for mathematical functions and
> logical functions depending on its arguments. This is just my
> preference and not really for efficiency. I would like to think
> that A FUNCTION computes something from something, a SUBROUTINE
> does something to something
An important consideration should also be whether there are
side-effects, on both the argument and on the state of the machine.
IMO, FUNCTIONs should not have side-effects, and also not depend on the
state of the world (machine), but should only depend on their inputs,
and not modify them. So RANDOM_NUMBER, though it may seem like a good
function, is a subroutine. These is just a guideline, and C programmers
may not follow it due to being used to functions with side-effects...
Finally, if something calculates more than one output from certain
inputs, it is hard to write it as a function anyway (which returns one
this), so better not even try unless there is a good reason.
Best,
Aleks
|