Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12703 > unrolled thread
| Started by | William Gill <noreply@domain.invalid> |
|---|---|
| First post | 2011-09-03 12:15 -0400 |
| Last post | 2011-09-05 18:55 -0400 |
| Articles | 5 on this page of 25 — 11 participants |
Back to article view | Back to comp.lang.python
Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 12:15 -0400
Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-04 02:25 +1000
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-03 15:15 -0400
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:34 -0400
Re: Functions vs OOP Ben Finney <ben+python@benfinney.id.au> - 2011-09-04 07:39 +1000
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-03 17:58 -0400
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-03 21:51 -0400
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 22:18 -0400
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-05 14:58 -0400
Re: Functions vs OOP MRAB <python@mrabarnett.plus.com> - 2011-09-03 17:29 +0100
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:09 -0400
Re: Functions vs OOP Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-03 12:50 -0600
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:13 -0400
Re: Functions vs OOP tinnews@isbd.co.uk - 2011-09-04 09:13 +0100
Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-04 21:18 +1000
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-04 14:32 -0400
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-04 15:43 -0400
Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-05 09:41 +1000
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-04 20:46 -0400
Re: Functions vs OOP Chris Angelico <rosuav@gmail.com> - 2011-09-05 10:59 +1000
Re: Functions vs OOP rusi <rustompmody@gmail.com> - 2011-09-04 06:13 -0700
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-05 13:45 -0400
Re: Functions vs OOP Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-09-05 21:04 +0200
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-05 20:30 -0400
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-05 18:55 -0400
Page 2 of 2 — ← Prev page 1 [2]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2011-09-04 06:13 -0700 |
| Message-ID | <d6c071ac-2def-44a1-baa5-a545d2988def@a10g2000prn.googlegroups.com> |
| In reply to | #12703 |
On Sep 3, 9:15 pm, William Gill <nore...@domain.invalid> wrote: > During some recent research, and re-familiarization with Python, I came > across documentation that suggests that programming using functions, and > programming using objects were somehow opposing techniques. Staying with (for the moment) the suggestion that OO-P and F-P are complementary, I believe it is worthwhile to distinguish syntactic OO- P vs F-P from semantic OO-P vs F-P. Syntactically: f(x) is functional x.f() is object oriented. Semantically if f's return value depends only on x ie does not depend on state it is functional (in the math sense) -- the jargon is that f is referentially transparent. Referential opaqueness is usually such a source of problems that it turns out good to contain the problem somewhat -- hence the wish for encapsulation. One can find in the python library itself all 4 combinations: syntactically and semantically OO : sort syntactically and semantically FP: sorted syntactically OO semantically FP: join
[toc] | [prev] | [next] | [standalone]
| From | William Gill <noreply@domain.invalid> |
|---|---|
| Date | 2011-09-05 13:45 -0400 |
| Message-ID | <j431q1$rrl$1@dont-email.me> |
| In reply to | #12739 |
On 9/4/2011 9:13 AM, rusi wrote: > On Sep 3, 9:15 pm, William Gill<nore...@domain.invalid> wrote: >> During some recent research, and re-familiarization with Python, I came >> across documentation that suggests that programming using functions, and >> programming using objects were somehow opposing techniques. > > Staying with (for the moment) the suggestion that OO-P and F-P are > complementary, I believe it is worthwhile to distinguish syntactic OO- > P vs F-P from semantic OO-P vs F-P. > > Syntactically: f(x) is functional x.f() is object oriented. > Semantically if f's return value depends only on x ie does not depend > on state it is functional (in the math sense) -- the jargon is that f > is referentially transparent. Not to split hairs, but syntactically f(x) is a function in many programming paradigms. As I understand it functional programming places specific requirements on functions, i.e.referential transparency. So f(x) may or may not be "functional". x.f() is also a function, but it is a member of the object x, is referred to as a 'method' of x, and uses the syntactical "dot" notation object"dot"function for identification. > Referential opaqueness is usually such a source of problems that it > turns out good to contain the problem somewhat -- hence the wish for > encapsulation. > > One can find in the python library itself all 4 combinations: > syntactically and semantically OO : sort > syntactically and semantically FP: sorted > syntactically OO semantically FP: join
[toc] | [prev] | [next] | [standalone]
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
|---|---|
| Date | 2011-09-05 21:04 +0200 |
| Message-ID | <mailman.780.1315249547.27778.python-list@python.org> |
| In reply to | #12786 |
William Gill wrote: > > Not to split hairs, but syntactically f(x) is a function in many > programming paradigms. > > As I understand it functional programming places specific requirements > on functions, i.e.referential transparency. So f(x) may or may not be > "functional". > > x.f() is also a function, but it is a member of the object x, is > referred to as a 'method' of x, and uses the syntactical "dot" > notation object"dot"function for identification. > Functional programming is not about writing a programm with functions (google it for more info). This may cause some confusion. Your original post was about functions vs methods, which are identical except some syntax detail. FYI, in python x.f() is equivalent to f(x). In an OOP world one will prefer the x.f() form. JM
[toc] | [prev] | [next] | [standalone]
| From | William Gill <nospam@domain.invalid> |
|---|---|
| Date | 2011-09-05 20:30 -0400 |
| Message-ID | <j43pju$s3j$1@dont-email.me> |
| In reply to | #12788 |
On 9/5/2011 3:04 PM, Jean-Michel Pichavant wrote: > William Gill wrote: >> >> Not to split hairs, but syntactically f(x) is a function in many >> programming paradigms. >> >> As I understand it functional programming places specific requirements >> on functions, i.e.referential transparency. So f(x) may or may not be >> "functional". >> >> x.f() is also a function, but it is a member of the object x, is >> referred to as a 'method' of x, and uses the syntactical "dot" >> notation object"dot"function for identification. >> > > Functional programming is not about writing a programm with functions > <snip>. This may cause some confusion. It can, and it did. That was the impression I (incorrectly) got from the documentation. Which didn't make sense to me. > (google it for more info). I can, and I did. That, and the answers I got in this ng are how I corrected my misconception. > > Your original post was about functions vs methods, which are identical > except some syntax detail. FYI, in python x.f() is equivalent to f(x). > In an OOP world one will prefer the x.f() form. > No, my original post was about how (based on the aforementioned misconception) the documentation seemed to suggest that OOP should never have free standing functions, only methods.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-09-05 18:55 -0400 |
| Message-ID | <mailman.783.1315263399.27778.python-list@python.org> |
| In reply to | #12786 |
On 9/5/2011 1:45 PM, William Gill wrote: > On 9/4/2011 9:13 AM, rusi wrote: >> On Sep 3, 9:15 pm, William Gill<nore...@domain.invalid> wrote: >>> During some recent research, and re-familiarization with Python, I came >>> across documentation that suggests that programming using functions, and >>> programming using objects were somehow opposing techniques. >> >> Staying with (for the moment) the suggestion that OO-P and F-P are >> complementary, I believe it is worthwhile to distinguish syntactic OO- >> P vs F-P from semantic OO-P vs F-P. >> >> Syntactically: f(x) is functional x.f() is object oriented. >> Semantically if f's return value depends only on x ie does not depend >> on state it is functional (in the math sense) -- the jargon is that f >> is referentially transparent. > > Not to split hairs, but syntactically f(x) is a function in many > programming paradigms. > > As I understand it functional programming places specific requirements > on functions, i.e.referential transparency. So f(x) may or may not be > "functional". In Python, it may be a parameterized procedure. Some languages separate functions and procedures (also called subroutines). Python does not. (Or you could say that it makes procedures into functions with side-effects by returning None by default). > x.f() is also a function, but it is a member of the object x, is > referred to as a 'method' of x, and uses the syntactical "dot" notation > object"dot"function for identification. > >> Referential opaqueness is usually such a source of problems that it >> turns out good to contain the problem somewhat -- hence the wish for >> encapsulation. >> >> One can find in the python library itself all 4 combinations: >> syntactically and semantically OO : sort >> syntactically and semantically FP: sorted >> syntactically OO semantically FP: join > -- Terry Jan Reedy
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web