[Types-sig] Re: A late entry

Jeremy Hylton jeremy-home@cnri.reston.va.us
Fri, 17 Mar 2000 11:56:42 -0500 (EST)


>I think it would be good to allow parameter-based method overloading
>for people who use the type system.  You'd be allowed to do stuff like:
>
>class Formatter:
>  def print(self: Formatter, i : integer)->None: ...
>  def print(self: Formatter, s : string)->None:  ...
>  def print(self: Formatter, l : ['a])->None: ...

I have been uneasy about OR types, too.  I think the primary source of 
OR-ing is default arguments and various methods that implement
Pythonic method overloading.  If we allow method overloading in the
type system -- to describe multiple valid signatures of a single
method object -- we might eliminate many of the problems.

class Foo:
    decl __init__(self, arg1: int, arg2: int)
    decl __init__(self, arg1: string)
    def __init__(self, arg1=None, arg2=None):
        [...]

I think this is a little simpler than the propopsal you made.  It
merely provides a mechanism to define simple types for existing Python 
code.

The other significant source of OR types is treating None as a
distinct type, which requires an OR type anywhere that you want to
pass an object or None.  If we also eliminate that, there is little
need for OR types.

-- Jeremy Hylton <http://www.python.org/~jeremy/>