[Python-3000] Types related to Syntax

2006-12-07 Thread Ron Adam
I don't normally start threads, but I wasn't sure who to post this as a reply to. This thought or direction of discussion, seems like it may be a useful viewpoint in the type/interface topics. Python's syntax interacts strongly with a number of basic types. For example (and in general) a

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Dave Anderson
on 12/7/2006 6:40 PM Greg Ewing wrote: > Dave Anderson wrote: > >> def get_name(arg: AnyClass.name):# AnyClass will magically have >> return arg.name()# a reference to any method name >> # somehow > > What if you want to say that arg has more > than one such m

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Greg Ewing
Dave Anderson wrote: > def get_name(arg: AnyClass.name): # AnyClass will magically have > return arg.name() # a reference to any method name > # somehow What if you want to say that arg has more than one such method? -- Greg Ewing, C

Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Steven Bethard
On 12/7/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > Let me throw out an examples of how this could look. > >@implements(sequence.__getitem__, sequence.__len__) >class MySequence: ># > >@implements(mapping.__getitem__, mapping.keys, mapping.__len__) >class MyMapping: >

Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Baptiste Carvello
Tim Hochberg a écrit : > > Here goes: to the extent that the semantics aren't clear from the > methods it is sufficient, and preferable, to attach the semantic > information to the methods rather their associated class. > which imho is the whole of the question: which level of granularity is d

Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Tim Hochberg
Talin wrote: > Phillip J. Eby wrote: >> At 09:59 AM 12/5/2006 -0600, Guido van Rossum wrote: >>> My point is that an interface can *document* (at least in English) a >>> "contract" about the invariants between operations. While I'm not into >>> enforcing or verifying such contracts, I'm very intere

Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Neil Toronto
Guido van Rossum wrote: > That sounds like a reasonable summary to me. One nit below. > Ditto. It was nice to see all the ambiguity cleared up in one fell swoop. Nicely done. > On 12/7/06, Talin <[EMAIL PROTECTED]> wrote: > >> [2] The reason I think 'interface' are misleading is due to its

Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Guido van Rossum
That sounds like a reasonable summary to me. One nit below. On 12/7/06, Talin <[EMAIL PROTECTED]> wrote: > Phillip J. Eby wrote: > > At 09:59 AM 12/5/2006 -0600, Guido van Rossum wrote: > >> My point is that an interface can *document* (at least in English) a > >> "contract" about the invariants b

Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Talin
Phillip J. Eby wrote: > At 09:59 AM 12/5/2006 -0600, Guido van Rossum wrote: >> My point is that an interface can *document* (at least in English) a >> "contract" about the invariants between operations. While I'm not into >> enforcing or verifying such contracts, I'm very interested in >> document

Re: [Python-3000] A better way to initialize PyTypeObject

2006-12-07 Thread Talin
Fredrik Lundh wrote: > Talin wrote: > >> OK. Its easy to implement either way. I coded up a string-based version, >> but if you guys want integer constants that's fine with me; probably >> best to let Fredrik & Larry tweak their patch rather than me continuing >> along this path since their stuff

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Bill Janssen
> But, looking > at the ABC page right now, to implement Dict, I'll need to inherit > Mapping and MutableContainer. Dave, I completely feel your pain. I think dict is overly complex (and Mapping). Almost nobody needs a whole "dict" -- it's become a grab bag for handy tricks to perform with map

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Dave Anderson
on 12/7/2006 11:25 AM Bill Janssen wrote: >> To me, even if Car happens to represent a dict by being able to be used >> as a dict, the expression of this fact feels better expressed as merely >> implementing dict. >> >> compare: >> >> class Car(dict): # car... is a dict? hmm, a bad ring to

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Bill Janssen
Dave, thanks. > To me, even if Car happens to represent a dict by being able to be used > as a dict, the expression of this fact feels better expressed as merely > implementing dict. > > compare: > > class Car(dict): # car... is a dict? hmm, a bad ring to it > ... > > class Car: >

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Dave Anderson
on 12/7/2006 10:57 AM Hasan Diwan wrote: > On 07/12/06, Dave Anderson <[EMAIL PROTECTED]> wrote: >> >> >> I feel on a different page from you. >> >> My best guess it is that >> >> def typeOfSuper(self): >> pass(subclass) >> >> is ceding its implementation to its subclasses, kind of like wh

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Hasan Diwan
On 07/12/06, Dave Anderson <[EMAIL PROTECTED]> wrote: > > > I feel on a different page from you. > > My best guess it is that > > def typeOfSuper(self): > pass(subclass) > > is ceding its implementation to its subclasses, kind of like what an > abstract class or interface would do > > but I

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Dave Anderson
on 12/7/2006 10:06 AM Hasan Diwan wrote: > The parametrized version of the pass keyword could be used to indicate a > formal interface. > > I may be missing something here, but we already have a mechanism for > defining that a object defines certain methods. Could we not keep it > orthogonal

Re: [Python-3000] A better way to initialize PyTypeObject

2006-12-07 Thread Fredrik Lundh
Talin wrote: > OK. Its easy to implement either way. I coded up a string-based version, > but if you guys want integer constants that's fine with me; probably > best to let Fredrik & Larry tweak their patch rather than me continuing > along this path since their stuff is further along. wouldn't i

Re: [Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

2006-12-07 Thread Hasan Diwan
The parametrized version of the pass keyword could be used to indicate a formal interface. On 07/12/06, Dave Anderson <[EMAIL PROTECTED]> wrote: Has-Method Contracts The first thing I loved about python (coming from java), was this realization that I was no longer need be