[Python-3000] pep 3124 plans
Jim Jewett
jimjjewett at gmail.com
Mon Jul 30 21:00:46 CEST 2007
On 7/30/07, Jeffrey Yasskin <jyasskin at gmail.com> wrote:
> On 7/29/07, Talin <talin at acm.org> 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
More information about the Python-3000
mailing list