... a function is a subroutine ... that returns a value (or a list of values).
In general, your distinction between function and subroutine as, respectively, returning or not returning a value seems of little use. Is there really any formal distinction here in any language?
In some programming languages, such as C, you can define either a "pure" subroutine or a function ...
I'm confused by your use of the term "pure" as it relates to subroutines/functions. As I understand it, a pure function is one whose behavior is not affected in any way by the state of the system in which it's running, has no effect upon the system other than by its return value, and creates no persistent state; the function has no "side effects." Any language can have such functions. As such, a pure function returning void would be useless. (Some languages allow the definition of functions with a pure attribute and purity is enforced by the compiler, but I'm not aware that ISO-C is one of them; I may be behind the latest standard here. (FWIW, a little Googling shows that GNU C has an __attribute__ "pure" feature.)) Your myfunction() C function is operationally pure; your myroutine() function is not: it has the side effect of assignment to the z variable and the effect of this assignment persists after the function terminates execution. (All three of the Perl functions you give as examples are operationally pure, but as you say, Perl neither defines nor enforces any formal notion of function purity.)
Update: See the discussion of the implementation of Pure Functions in the D language.
Give a man a fish: <%-{-{-{-<
In reply to Re^4: I'm trying to consolidate my functions into subroutines
by AnomalousMonk
in thread I'm trying to consolidate my functions into subroutines
by Peter Keystrokes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |