Re: an oop question

2022-11-05 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: >>r...@zedat.fu-berlin.de (Stefan Ram) writes: >>>Later, I looked at a book in a bookstore; it was a book >>>about programming by Barbara Liskov that came out after the >>>LSP was already mentioned often, and as far as I could se

Re: an oop question

2022-11-04 Thread Julieta Shem
Greg Ewing writes: > On 4/11/22 1:29 am, Julieta Shem wrote: >> Perhaps I can reduce the >> class Pair to just being a pair as we know it, made of two things, then >> we create a class called Sequence, which is really a composition of >> Pairs, comes with a length method and we derive Stack from

Re: an oop question

2022-11-04 Thread Greg Ewing
On 5/11/22 4:25 am, Chris Angelico wrote: Maybe it's one of those terms that is useless for actual coding (because practicality beats purity), but good for discussions? I'm not sure it's much good for discussions, either. I don't really care whether a language is "purely OO" or not, whatever th

Re: an oop question

2022-11-04 Thread Chris Angelico
On Sat, 5 Nov 2022 at 02:18, Greg Ewing wrote: > > On 4/11/22 12:50 am, Chris Angelico wrote: > > In Python, everything is an object. Doesn't that equally mean that > > Python is purely OOP? > > Depends on what you mean by "purely oop". To me it suggests a > language in which dynamically-dispatche

Re: an oop question

2022-11-04 Thread Chris Angelico
On Sat, 5 Nov 2022 at 02:21, Greg Ewing wrote: > > > r...@zedat.fu-berlin.de (Stefan Ram) writes [that Barbara Liskov said]: > > > >> |If for each object o1 of type S there is an object o2 of > >> |type T such that for all programs P defined in terms of T, > >> |the behavior of P is unchanged when

Re: an oop question

2022-11-04 Thread Greg Ewing
On 4/11/22 7:51 am, Julieta Shem wrote: (The empty documentation seems to satisfy the principle.) All the more reason to document your classes! More seriously, there's always at least a (possibly fuzzily) implied contract, because of the names you choose for things if nothing else. -- Greg -

Re: an oop question

2022-11-04 Thread Greg Ewing
r...@zedat.fu-berlin.de (Stefan Ram) writes [that Barbara Liskov said]: |If for each object o1 of type S there is an object o2 of |type T such that for all programs P defined in terms of T, |the behavior of P is unchanged when o1 is substituted for o2 |then S is a subtype of T. That seems over

Re: an oop question

2022-11-04 Thread Greg Ewing
On 4/11/22 12:50 am, Chris Angelico wrote: In Python, everything is an object. Doesn't that equally mean that Python is purely OOP? Depends on what you mean by "purely oop". To me it suggests a language in which dynamically-dispatched methods are the only form of code. Python is not one of thos

Re: an oop question

2022-11-04 Thread Greg Ewing
On 4/11/22 1:29 am, Julieta Shem wrote: Perhaps I can reduce the class Pair to just being a pair as we know it, made of two things, then we create a class called Sequence, which is really a composition of Pairs, comes with a length method and we derive Stack from it. That sounds better. But be

Re: an oop question

2022-11-03 Thread Weatherby,Gerard
https://www.oreilly.com/library/view/beginning-c-30/9780470261293/9780470261293_a_short_history_of_object-oriented_progr.html -- https://mail.python.org/mailman/listinfo/python-list

Re: an oop question

2022-11-03 Thread Alan Gauld
On 03/11/2022 18:29, Chris Angelico wrote: > On Fri, 4 Nov 2022 at 05:21, Julieta Shem wrote: >> >> Chris Angelico writes: >> >>> On Thu, 3 Nov 2022 at 21:44, Alan Gauld wrote: Also Python is not a purely OOP language, in that you can write functional and procedural code in Python if y

Re: an oop question

2022-11-03 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: >>I'll definitely look up the Liskov >>substitution principle and try to understand it. > > I found the LSP to be very confusing: > > First, it's was hard for me to actually get a clear sou

Re: an oop question

2022-11-03 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: [...] > 2. a. 1. Remark > > One can observe this ease especially when one defines a new > class with a standard verb and then standard procedures > "magically" use this new method, as in: > > class MyNewClass: > de

Re: an oop question

2022-11-03 Thread Chris Angelico
On Fri, 4 Nov 2022 at 05:21, Julieta Shem wrote: > > Chris Angelico writes: > > > On Thu, 3 Nov 2022 at 21:44, Alan Gauld wrote: > >> Also Python is not a purely OOP language, in that you can write > >> functional and procedural code in Python if you wish. In > >> Smalltalk thats notionally impo

Re: an oop question

2022-11-03 Thread Julieta Shem
Chris Angelico writes: > On Thu, 3 Nov 2022 at 21:44, Alan Gauld wrote: >> Also Python is not a purely OOP language, in that you can write >> functional and procedural code in Python if you wish. In >> Smalltalk thats notionally impossible because everything >> is an object. And all programming

Re: an oop question

2022-11-03 Thread Julieta Shem
Greg Ewing writes: > On 3/11/22 1:37 pm, Julieta Shem wrote: >> The code for computing the length of a Pair (which is really a linked >> list) happens to be the same for computing the length of a Stack. > > I would question whether that should be a method of Pair at all, > since it's not the leng

Re: an oop question

2022-11-03 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: >>That's very interesting. Would you share the complete thread of e-mail? >>I would love to read it word for word. > > Yes, with pleasure! A quotation from my corresponding web page: > > (For technical reasons, the web page

Re: an oop question

2022-11-03 Thread Chris Angelico
On Thu, 3 Nov 2022 at 21:44, Alan Gauld wrote: > Also Python is not a purely OOP language, in that you can write > functional and procedural code in Python if you wish. In > Smalltalk thats notionally impossible because everything > is an object. And all programming statements are messages > to ob

Re: an oop question

2022-11-03 Thread Weatherby,Gerard
From: Python-list on behalf of Alan Gauld Date: Thursday, November 3, 2022 at 6:45 AM To: Julieta Shem , python-list@python.org Subject: Re: an oop question *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On 03/11/2022 00:25

Re: an oop question

2022-11-03 Thread Alan Gauld
On 03/11/2022 00:25, Julieta Shem wrote: >> |OOP to me means only messaging, local retention and protection and >> |hiding of state-process, and extreme late-binding of all things. > > I'm wondering how Python fails to satisfy his definition. Python doesn't do any form of data protection/hiding.

Re: an oop question

2022-11-02 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Greg Ewing writes: >>I don't see any overlap between these at the conceptual level. > > It might come from early LISP dialects. In early LISPs, the > only basic means to combine data into a larger assembly of > data was the dotted pair and NULL

Re: an oop question

2022-11-02 Thread Greg Ewing
On 3/11/22 1:37 pm, Julieta Shem wrote: The code for computing the length of a Pair (which is really a linked list) happens to be the same for computing the length of a Stack. I would question whether that should be a method of Pair at all, since it's not the length of the pair itself, but the

Re: an oop question

2022-11-02 Thread Julieta Shem
Alan Gauld writes: > On 01/11/2022 17:58, Julieta Shem wrote: [...] >>> IS-A relationship, so Stack inheriting Pair would mean that a Stack >>> was a Pair. That is not really true. >> >> That's another interesting observation. I do not have much >> understanding of how to really think of thes

Re: [correction]an oop question

2022-11-02 Thread Julieta Shem
Dennis Lee Bieber writes: > On 2 Nov 2022 09:56:28 GMT, r...@zedat.fu-berlin.de (Stefan Ram) declaimed > the following: > > >> Now, in the next program, I have removed the subclassings, >> there is no inheritance from the base class "Language" >> anymore. Yet the polymorphism in "f" still work

Re: an oop question

2022-11-02 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: >>Any book recomendations on getting this thing mathematics-clear? > > OOP cannot be mathematics-clear because it is an /attempt/ to > abstract from several different programming languages. > > When you ask Alan Kay (and I

Re: an oop question

2022-11-02 Thread Julieta Shem
Greg Ewing writes: > On 2/11/22 9:54 am, Julieta Shem wrote: >> But we've left behind a more basic requirement --- the Stack >> class wishes for all the methods already written in some class called >> Pair, > > Is that *really* what you want, though? > > To my way of thinking, a Stack and a Pair

Re: [correction]an oop question

2022-11-02 Thread Alan Gauld
On 02/11/2022 20:21, Dennis Lee Bieber wrote: >> shows that in Python we do *not* need subclassing/inheritance >> for polymorphism! >> > To me, that is not really an example of polymorphism, but more an > example of Python's "duck typing". But duck typing is a perfectly good implementatio

Re: an oop question

2022-11-02 Thread Alan Gauld
On 01/11/2022 17:58, Julieta Shem wrote: > nowhere in trying to detect in high-precision what is OOP and what is > not. Stefan has given a good answer but essentially OOP is a program that is structured around objects communicating by sending messages to one another. Objects are, in most (but n

Re: an oop question

2022-11-02 Thread Greg Ewing
On 2/11/22 9:54 am, Julieta Shem wrote: But we've left behind a more basic requirement --- the Stack class wishes for all the methods already written in some class called Pair, Is that *really* what you want, though? To my way of thinking, a Stack and a Pair are quite different data structures

Re: an oop question

2022-11-01 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: >>The crucial feature OOP adds to this is polymorphism ("late binding"). > > If polymorphism is so crucial, the idea of subclasses > has something to it! [...] I wonder what Rich Hickey would say here

Re: an oop question

2022-11-01 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: >>clarify. If I wish for an empty stack, I wish I could just say > Stack() >>Stack() >>and if I wish for a nonempty stack, I'd write > Stack(1, Stack(2, Stack(3, Stack( >>Stack(1, Stack(2, Stack(3, Stack( > > I

Re: an oop question

2022-11-01 Thread Weatherby,Gerard
22 at 3:43 PM To: python-list@python.org Subject: Re: an oop question *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Julieta Shem writes: >clarify. If I wish for an empty stack, I wish I could just say >>>> Stack()

Re: an oop question

2022-11-01 Thread Julieta Shem
Alan Gauld writes: > On 30/10/2022 14:01, Julieta Shem wrote: > >> I wrote the classes >> >> class Empty: >> ... >> class Pair: >> ... >> >> (*) How to build a stack? >> >> These Lisp-like sequences are clearly a stack. > > That is a very important observation. A Pair IS-A Stack(

Re: an oop question

2022-11-01 Thread Julieta Shem
Chris Angelico writes: > On Mon, 31 Oct 2022 at 14:38, Julieta Shem wrote: >> >> Chris Angelico writes: >> >> > The most straight-forward way to represent this concept in an >> > object-oriented way is subclassing. >> > >> > class Stack: >> > ... # put whatever code is common here >> > >> >

Re: an oop question

2022-10-31 Thread Alan Gauld
On 30/10/2022 14:01, Julieta Shem wrote: > I wrote the classes > > class Empty: > ... > class Pair: > ... > > (*) How to build a stack? > > These Lisp-like sequences are clearly a stack. That is a very important observation. A Pair IS-A Stack(sort of). If you had a stack you coul

Re: an oop question

2022-10-30 Thread Chris Angelico
On Mon, 31 Oct 2022 at 14:38, Julieta Shem wrote: > > Chris Angelico writes: > > > The most straight-forward way to represent this concept in an > > object-oriented way is subclassing. > > > > class Stack: > > ... # put whatever code is common here > > > > class Empty(Stack): > > ... # pu

Re: an oop question

2022-10-30 Thread Julieta Shem
Chris Angelico writes: > On Mon, 31 Oct 2022 at 09:05, Julieta Shem wrote: >> >> Julieta Shem writes: >> >> [...] >> >> >> . If you should, however, be talking about the new "type hints": >> >> These are static and have "Union", for example, "Union[int, str]" >> >> or "int | str". >> > >>

Re: an oop question

2022-10-30 Thread dn
On 31/10/2022 09.22, Stefan Ram wrote: Giorgio Pastore writes: You may find useful to learn about the possibilities of using Python tools to implement a stack data structure and its manipulation methods. A good introduction is at https://realpython.com/how-to-implement-python-stack/ I can'

Re: an oop question

2022-10-30 Thread Weatherby,Gerard
same interface create an abstract base class and derive both of them from it. https://docs.python.org/3/library/abc.html From: Python-list on behalf of Julieta Shem Date: Sunday, October 30, 2022 at 5:51 PM To: python-list@python.org Subject: an oop question *** Attention: This is an

Re: an oop question

2022-10-30 Thread Chris Angelico
On Mon, 31 Oct 2022 at 09:05, Julieta Shem wrote: > > Julieta Shem writes: > > [...] > > >> . If you should, however, be talking about the new "type hints": > >> These are static and have "Union", for example, "Union[int, str]" > >> or "int | str". > > > > I ended up locating such features

Re: an oop question

2022-10-30 Thread Giorgio Pastore
Il 30/10/22 15:54, Julieta Shem ha scritto: r...@zedat.fu-berlin.de (Stefan Ram) writes: Julieta Shem writes: My desire seems to imply that I need a union-like data structure. You only need to worry about such things in languages with static typing. For example, to have a function tha

Re: an oop question

2022-10-30 Thread Julieta Shem
Julieta Shem writes: [...] >> . If you should, however, be talking about the new "type hints": >> These are static and have "Union", for example, "Union[int, str]" >> or "int | str". > > I ended up locating such features of the language in the documentation, > but I actually am not interes

Re: an oop question

2022-10-30 Thread Julieta Shem
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Julieta Shem writes: >>My desire seems to imply that I need a union-like data structure. > > You only need to worry about such things in languages with > static typing. For example, to have a function that can > sometimes return an int value an

an oop question

2022-10-30 Thread Julieta Shem
I have a question about a particular case I'm working on. I'm studying OOP. To ask the question, I'm going to have to introduce you my context here, so you'll need to bear with me. If you'd like to see the question right away, go to the section ``My difficulty in encapsulating a union''. (*) In