[Types-sig] New syntax?

Martijn Faassen m.faassen@vet.uu.nl
Thu, 16 Dec 1999 21:26:57 +0100


Paul Prescod wrote:
> 
> There are two separate issues here. Separate files and separate
> syntaxes. And there are two different time periods here: today and in
> Python 2.
> 
> Separate files are a necessity to handle C-coded types.

Um? Why?

> Ergo anything on
> top of that is more work and given that we are still talking about
> something useful in a month (though that is looking less and less
> likely) I am not inclined to take on the extra work of new operators and
> an inline syntax.

What about putting this extra information inside the module file itself?
You need a separate file because you want to come up with your own
syntax, but even then you can do:

__types__ = """

def foo(int, int):
    hey: int
    hoi: [int]
    result: string

bar: string

grok: [string]

class Mine:
    hm : float

    def __init__(self, int, string):
        self.yahoo: [int]
        self.dict: {string : int}
        temp: int
    
    def getYahoo(self):
        result: [int]

def more(Mine, Mine):
    temp: int
    result: Mine

class Parametric:
    firstparam: param
    secondparam: param

    def __init__(self):
        self.a: firstparam
        self.b: secondparam
    
    def hullo(self):
        result: firstparam

whoops: Parametric(string, float)

def optional(int, *(int, string, int)):
    pass

def anotheroptional(int, *[Mine]):
    pass

union: int or string

"""

which incidentally would be a neat Pythonic syntax. :)

Regards,

Martijn