Functions vs OOP
rosuav at gmail.com
Sun Sep 4 20:59:59 EDT 2011
On Mon, Sep 5, 2011 at 9:41 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> What about the entire "Introduction" section, which starts with this
> "This section explains the basic concept of functional programming"
> If you would like to suggest improvements, please do so.
Well, it does invite you to skip that whole section :)
Since you asked, though, the copyeditor in me does want to suggest one
Second paragraph after the bullet list ends "Avoiding side effects
means not using data structures that get updated as a program runs;
every function’s output must only depend on its input." - I'd word it
as "must depend only on". Pretty immaterial, but the formal style
Somewhat more significant: Under "Modularity", may be of value to add
a paragraph about parallelism.
With functional code, it's easy for an interpreter to ascertain which
functions depend on each other (because one's return value is
another's input). Independent functions can be run in parallel without
affecting the result; the interpreter can therefore divide a complex
task across multiple CPUs without any work from the programmer.
Like I said, it's just "since you asked". :) The above paragraph is
hereby given out as public domain, use it (edit it, whatever) under
whatever license the Python docs require.
More information about the Python-list