[Types-sig] New syntax?

Martijn Faassen m.faassen@vet.uu.nl
Thu, 16 Dec 1999 23:19:50 +0100


Greg Stein wrote:
> 
> On Thu, 16 Dec 1999, Martijn Faassen wrote:
> 
> >... example syntax for a Python syntax to declare interfaces ...
> 
> Ah. Good. That is better than your/Paul's previous suggestions.

It was almost exactly the same as before, though.

> > > Inline vs. external is a different question (and I vote for former). But
> > > different syntaxes is a big problem that is easily avoided.
> >
> > So what are you suggesting if you would be voting for external, then? A
> > Python based system such as the one I proposed earlier? Or is this why
> > you're voting for internal?
> 
> By "for former", I meant that I want an internal syntax.

Yes, I understood that. I just was curious what you meant when you
stated you'd be something parsed with Python anyway, even if it were
external. It's hard to come up with external type annotation syntax that
doesn't include a new language.

> Something like
> Tim's suggestion. It keeps the declaration closest to the implementation,
> which (IMO) is best. It is kind of like comments and code: they can easily
> drift apart, especially if the two are distant from each other.

That's true. It is a disadvantage.

> In your example above, I think it would be a bit painful to flip back and
> forth between the "class" and "varclass" every time you wanted to add a
> method.

Yes, but I think my proposal is rather easy to understand for Python
programmers, as it looks almost exactly like Python in structure. The
flipping back and forth is a bit painful, though, I agree. The advantage
of separation though is that it can actually be made to look exactly
like Python structures, which is rather neat.
 
[snip]

> [ I *really* don't like member declarations in the __init__() method as
>   some people have shown. Those could be confused with declarations of
>   local vars, which I hope we aren't going to have. ]

Well, my syntax proposal avoids this confusion by following Python's
lead:

varclass Foo:
   alpha: int

   def __init__(self):
       self.member: int
       local: int
    
> Consider the above example, my latest proposal for syntax changes in
> support of declarations. Obviously, a bit more detail is needed for things
> like parameterized types, but I think the above is representative of where
> I'd like to see things go.

Didn't you think parameterized types looked fairly straightforward in my
syntax proposal?
 
> And I won't suggest anything for an external syntax, since I don't support
> that :-)

Right, that was what I was curious about. :)

Regards,

Martijn