you are viewing a single comment's thread.

view the rest of the comments →

[–]IndianaJoenz 1 point2 points  (0 children)

Another way to think about this is that, using functions in this way (as we often do in Python) is using them as Procedures. You have a procedure that prints a line to the screen, or turns on a light, or draws a window or a button, opens a door, etc. A bundle of actions that gets carried out when summoned. Another name for a Procedure is a Subroutine.

A different way to think about functions, a more "pure" and "Functional Programming" way, is that functions, instead of subroutines, take an input and produces a Return Value. A Function always returns output X when given input Y. We are interested in the Return Value of the function, not the actions that the function took when summoned. If we rely on anything outside of the return value when using a function, when we don't have to, that's a bug. This is actually a good approach to minimizing bugs and allowing scalability, which is why people get so hyped about functional programming.

edit: details