On 7/30/07, Jeffrey Yasskin <[EMAIL PROTECTED]> wrote:
> On 7/29/07, Talin <[EMAIL PROTECTED]> wrote:
> > Phillip J. Eby wrote:
> > > At 08:25 AM 7/27/2007 -0700, Guido van Rossum wrote:
> > >> ... But GFs in classes and subclassing? Not until we
> > >> have a much better design.

> > > The only time I actually use them in
> > > classes myself is to override existing generic functions
> > > that live outside the class

Why are you overriding, instead of just specializing?

Why not define the @overload operator so that it just registers the
specialization with the base class?


> >     class A:
> >        @overload
> >        def method1(self, x:object):
> >           ...

Should this register with a "global" generic method, so that

    method1(first_arg:A, x:object)

forwards to

    A.method1(first_arg, x)

> >     class B(A):
> >        @overload
> >        def method(self, x:int):
> >           ...

and this would register with A.method1 (or the global method1,
depending on the previous answer) for the pattern

    method1(first_arg:B, x:int)

> >     b = B()
> >     b.method("test") // Method not found

Instead, this would skip back to A.method1(self, "test") -- and I
think the @overload decorator is sufficient warning.  (I do wonder
whether that is magical enough to call it @__overload__)

-jJ
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to