Functions vs OOP

Chris Angelico rosuav at gmail.com
Mon Sep 5 02:59:59 CEST 2011


On Mon, Sep 5, 2011 at 9:41 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> http://docs.python.org/dev/howto/functional.html
>
> What about the entire "Introduction" section, which starts with this
> statement?
>
> "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
small tweak:

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
prefers correctness.

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.

ChrisA



More information about the Python-list mailing list