Re: on implementing a toy oop-system

2022-09-29 Thread Meredith Montgomery
r...@zedat.fu-berlin.de (Stefan Ram) writes: [...] >>>However, to evaluate a method call such as "o.m( a, a1, ... )", >>>currying does not necessarily have to be used. One can as well >>>determine the function to be used for "m" from the type of "o" >>>and then call that function with arguments

Re: on implementing a toy oop-system

2022-09-29 Thread Meredith Montgomery
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Meredith Montgomery writes: >>The code below works, but you can see it's kinda ugly. I wish I could >>uncurry a procedure, but I don't think this is possible. (Is it?) > > from functools import partial > from operator import add > add5 = partial( a

Re: on implementing a toy oop-system

2022-09-28 Thread Meredith Montgomery
Meredith Montgomery writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> Meredith Montgomery writes: >>>Is that at all possible somehow? Alternatively, how would you do your >>>toy oop-system? >> >> Maybe something along those lines: >> >> from functools import partial >> >> def counte

Re: on implementing a toy oop-system

2022-09-23 Thread Meredith Montgomery
Chris Angelico writes: > On Sat, 24 Sept 2022 at 07:52, Meredith Montgomery > wrote: >> >> def Counter(name = None): >> o = {"name": name if name else "untitled", "n": 0} >> def inc(o): >> o["n"] += 1 >> return o >> o["inc"] = inc >> def get(o): >> return o["n"] >> o["get"]

Re: on implementing a toy oop-system

2022-09-23 Thread Chris Angelico
On Sat, 24 Sept 2022 at 07:52, Meredith Montgomery wrote: > > def Counter(name = None): > o = {"name": name if name else "untitled", "n": 0} > def inc(o): > o["n"] += 1 > return o > o["inc"] = inc > def get(o): > return o["n"] > o["get"] = get > return o > Want a neat demo

Re: on implementing a toy oop-system

2022-09-23 Thread Meredith Montgomery
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Meredith Montgomery writes: >>Is that at all possible somehow? Alternatively, how would you do your >>toy oop-system? > > Maybe something along those lines: > > from functools import partial > > def counter_create( object ): > object[ "n" ]= 0

Re: on implementing a toy oop-system

2022-09-06 Thread Meredith Montgomery
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Meredith Montgomery writes: >>Is that at all possible somehow? Alternatively, how would you do your >>toy oop-system? > > Maybe something along those lines: > > from functools import partial > > def counter_create( object ): > object[ "n" ]= 0

on implementing a toy oop-system

2022-09-06 Thread Meredith Montgomery
Just for investigation sake, I'm trying to simulate OO-inheritance. (*) What did I do? I decided that objects would be dictionaries and methods would be procedures stored in the object. A class is just a procedure that creates such object-dictionary. So far so good. Trouble arrived when I