Functions vs OOP
nospam at domain.invalid
Sun Sep 4 21:43:31 CEST 2011
On 9/4/2011 2:32 PM, Terry Reedy wrote:
> On 9/4/2011 4:13 AM, tinnews at isbd.co.uk wrote:
>> Ian Kelly<ian.g.kelly at gmail.com> wrote:
>>> Functional programming is about using functions in the *mathematical*
>>> sense. A mathematical function maps one value (or tuple of values) to
>>> another value. The mapped value never varies; if it did, it would be
>>> a different function. So functional programming eschews the use of
>>> functions where the results depend on any internal or external state
>>> beyond the values of the passed-in arguments, such as the variable
>>> state of the object the method is being called on.
>> I think there may be another issue here. If someone says "functional
>> programming" to me then I would generally assume that they *do* mean
>> "programming using functions". While your distinction of the two may
>> be strictly correct I don't think it's the generally accepted meaning.
> The distintion drawn by Ian *is* generally accepted in computer science.
> For instance, programming is C is imperative programming with functions
> but it generally is not 'functional programming' in the sense referred
> to by Ian and the Wikipedia article. Given that our docs are written by
> people who do understand the technical distinction, you are probably
> wrong to assume otherwise.
> However, as I said to William, it is possible that our docs could be
> improved so as to not depend on all readers having prior knowledge of
> the intended meaning of 'functional programming'. As the use of Python
> has expanded, so has the variety of backgrounds of Python programmers.
Since I am the one who opened this can of worms, and since I believe I
have relocated the document that I misinterpreted, I feel compelled to
jump in here.
The source of my error is "Functional Programming HOWTO
Having arrived at this page indirectly (searching for and skimming other
information regarding functions and methods) I was only half paying
attention. As a result I made the same mistake Chris did.
As a point of reference, I would not call myself a programmer, and any
formal exposure was many, many years ago. I am familiar with the
concepts of procedural, declarative, and object-oriented programming,
but not functional. At least not in this context.
Having done a little more digging I now understand the difference.
"Functional programming" is the proper terminology, and had I come
across it from another direction, or with a more deliberate focus I
probably wouldn't have made the initial mistake.
If you read the material with even a nominal understanding of the
functional paradigm (functional relationships in a mathematical sense,
not functions in the procedural sense), it is clear. If you read it
without consciously recognizing this difference, the material does
nothing to alert you to the initial error.
More information about the Python-list