[Python-3000] Fw: typeclasses, duck-typing

Ben.Young at risk.sungard.com Ben.Young at risk.sungard.com
Fri May 12 10:01:59 CEST 2006


"Phillip J. Eby" <pje at telecommunity.com> wrote on 11/05/2006 17:18:39:

> At 04:27 PM 5/11/2006 +0100, Ben.Young at risk.sungard.com wrote:
> >Why not
> >
> >class Foo(object):
> >         @specialize(arg(0))
> >         def core.len(self)
> >                 ...
> 
> Where does 'core' come from?  What is specialize for?  I don't 
understand 
> what you're proposing.
> 

Sorry, I didn't make myself very clear. What I was trying to give the 
impression of was something like C#s explicit interface methods, but 
without declaring the class implements an interface, and without adding 
new syntax (i.e defop). I think I meant the same as you really (although 
the method would appear in the class dict somehow). The core bit is just 
to show you are overloading the len method, rather than just defining a 
len method (as I have dropped defop). The specialize bit just tells you 
what args the multimethod is dispatching on, similar to your x:class bit 
you mentioned.

I know it's not a clear idea at the moment. If I have some time to play, 
I'll have a think and see if I can make it more concrete.

Cheers,
Ben

> 
> >I don't know how this would appear in the class dict though? 
self.len()?
> 
> In my proposal, 'defop' doesn't bind anything; it's just a statement 
that 
> defines a function object and then adds that function to the specified 
> 
> 



More information about the Python-3000 mailing list