Re: [Python-3000] Type annotations: annotating generators

2006-05-20 Thread Greg Ewing
Guido van Rossum wrote: > I guess by "algebraic types" you meant enumerated types? An algebraic type is somewhat more than that -- think of it as something like a tagged tuple. A less degenerate example would be (using a more Haskell-like syntax): Tree t = Leaf t | Node (Tree t) (Tree t) Th

Re: [Python-3000] Type annotations: annotating generators

2006-05-20 Thread Greg Ewing
Nick Coghlan wrote: > Assume the following is true for a type annotation system: >(T,) is equivalent to tuple[T] >(T1, T2) is equivalent to tuple[T1, T2] >(T1, T2, T3) is equivalent to tuple[T1, T2, T3] > > but how do I use this system to spell the > type annotation for a tuple of un

Re: [Python-3000] Type parameterization

2006-05-20 Thread Greg Ewing
Travis E. Oliphant wrote: > I'm sorry to interrupt the resting, but I just wanted to remind > everybody that Numerical computing people would still like a way to > distinguish between "element-by-element" multiplication and tensor > contraction (matrix multiplication). A while back, there was

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Travis E. Oliphant
Guido van Rossum wrote: > On 5/20/06, Talin <[EMAIL PROTECTED]> wrote: >> As far as how to pick the set of operators, well my notion on that was > > I suggest you let this rest for now. We have plenty of existing > operators, and I'd rather wait for a more compelling reason to add > more. > I'm

Re: [Python-3000] Type annotations: annotating generators

2006-05-20 Thread Nick Coghlan
Collin Winter wrote: > On 5/19/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> OK; for the return value (only) the Function().returns() >> notation does look fairly pretty. >> >> I presume that return(int, int) is the same as return((int, int))? > > It is. > >> Weren't we going to write a tupl

Re: [Python-3000] Misc type annotation issues

2006-05-20 Thread Nick Coghlan
Guido van Rossum wrote: > On 5/20/06, Collin Winter <[EMAIL PROTECTED]> wrote: >> 3. What will annotations on *varargs and **varkw look like? My own >> suggestion is that >> > def foo(a: , *varargs: , **varkw: ) >> is fully equivalent to -- and is indeed coerced to -- >> > def foo(a: , *var

Re: [Python-3000] Type parameterization

2006-05-20 Thread Nick Coghlan
Jim Jewett wrote: > If the implementation of [] ends up doing the moral equivalent of > > (self.__getitem__(arg) if not isintance(self, type) else > self.__parameterization__(arg)) > > then we're running into problems with > > If the implementation is hard to explain, it's a bad idea. I

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Nick Coghlan
Jim Jewett wrote: > On 5/19/06, Collin Winter <[EMAIL PROTECTED]> wrote: >> B.__parameterize__ will only be called in the case of B[x] (as opposed >> to B()[x]). > > new-style classes (the ones sticking around for python 3) are also instances. > > >>> isinstance(dict, type) and isinstance(dic

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Phillip J. Eby
At 12:36 AM 5/20/2006 -0600, "Steven Bethard" <[EMAIL PROTECTED]> wrote: >On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > I've already addressed Steve's other issues. The blogs have the use > cases etc. > >I'm sorry, I guess I'm just dense, but here's the blogs I've read: > >http://ww

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Talin
Guido van Rossum wrote: > On 5/20/06, Talin <[EMAIL PROTECTED]> wrote: > >> As far as how to pick the set of operators, well my notion on that was >> to come up with a list of general mathematical and logical concepts, and >> see if any would be useful as operators. In other words, the placeholder

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Steven Bethard
On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 5/20/06, Steven Bethard <[EMAIL PROTECTED]> wrote: > > I guess in the end, I'm still a little confused at why we're having a > > syntax discussion now. If type annotations are just an extra > > expression in a function definition, why do

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Steven Bethard
On 5/20/06, Collin Winter <[EMAIL PROTECTED]> wrote: > On 5/20/06, Steven Bethard <[EMAIL PROTECTED]> wrote: > > I wandered around > > http://oakwinter.com/code/typecheck/ > > but couldn't find any discussion about the implications of, say, > > requring the type ``{str:Number}`` (which I assume

Re: [Python-3000] Type parameterization

2006-05-20 Thread Marcin 'Qrczak' Kowalczyk
Talin <[EMAIL PROTECTED]> writes: > (Now all I need is a friendly way to spell "Var('x')" and I'm all set.) var.x > Another question that springs to mind is, what about the converse > operator, '<-', and what does it represent? (Besides meaning "less > than the negative of", which is a troubling

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Guido van Rossum
On 5/20/06, Talin <[EMAIL PROTECTED]> wrote: > As far as how to pick the set of operators, well my notion on that was > to come up with a list of general mathematical and logical concepts, and > see if any would be useful as operators. In other words, the placeholder > operators would have general

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Guido van Rossum
On 5/20/06, Steven Bethard <[EMAIL PROTECTED]> wrote: > On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > You may have read my prototypes, which dispatch on concrete types. > > Phillip lets you dispatch on predicates like hasattr(x, 'append'). > > I assume you mean this one: > http://

Re: [Python-3000] Type annotations: annotating generators

2006-05-20 Thread Paul Boddie
Tony Lownds wrote: > > Paul Boddie wrote: > > > > What's the general opinion on systems which attempt to infer and > > predict inappropriate type usage? [...] > > Couldn't such systems be a better aid to program reliability? > > Would "optional" type declarations be relevant to the operation > >

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Talin
Guido van Rossum wrote: > On 5/19/06, Talin <[EMAIL PROTECTED]> wrote: > >> Side note: I'm actually in favor of the idea of Python adding >> syntactical support for operators that have no "built-in" definition. >> The use case would be for classes that define new operators that don't >> correspond

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Collin Winter
On 5/20/06, Steven Bethard <[EMAIL PROTECTED]> wrote: > On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Collin Winter's is pretty real, and I believe one other person (Tony > > Lownds?) has another. > > I wandered around > http://oakwinter.com/code/typecheck/ > but couldn't find any

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Steven Bethard
On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 5/20/06, Steven Bethard <[EMAIL PROTECTED]> wrote: > > And the only use-cases I could extract are: [snip] > > * function overloading[1]. I think Philip J. Eby had some interesting > > thoughts here, but in all the prototypes, dispatching

Re: [Python-3000] Use cases for type annotations?

2006-05-20 Thread Marcin 'Qrczak' Kowalczyk
"Steven Bethard" <[EMAIL PROTECTED]> writes: > (1) there were very few real implementations of the ideas, and > (2) where there was an implementation, it relied on concrete types Common Lisp has: - Classes ("concrete types"), with explicit subclassing, not parametrized, defined strictly, used

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Guido van Rossum
On 5/20/06, Tony Lownds <[EMAIL PROTECTED]> wrote: > How about just dict[str:int]? A bit too clever, although it happens to work syntactically -- it calls dict.__getitem__(slice(str, int)). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Guido van Rossum
On 5/20/06, Steven Bethard <[EMAIL PROTECTED]> wrote: > On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > I've already addressed Steve's other issues. The blogs have the use cases > > etc. > > I'm sorry, I guess I'm just dense, but here's the blogs I've read: > > http://www.artima.com/we

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Steven Bethard
On 5/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > I've already addressed Steve's other issues. The blogs have the use cases etc. I'm sorry, I guess I'm just dense, but here's the blogs I've read: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 http://www.artima.com/weblogs/viewpos

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Tony Lownds
On May 19, 2006, at 9:23 PM, Talin wrote: > > OK, try this on your friends and see what happens: > > dict[ str >> int ] > How about just dict[str:int]? > Alternative suggestion: Define -> as an operator. > I like this idea! -Tony ___ Python-30

Re: [Python-3000] Anti-use-case for type annotations

2006-05-20 Thread tomer filiba
Guido writes: > You can then write a decorator that does something with these. Or you > can just use them as documentation. The decorators don't have to do > type checking; they can do whatever you like; that's why there is no > semantic constraint on the type annotations. well, if that's the case

Re: [Python-3000] Misc type annotation issues

2006-05-20 Thread Guido van Rossum
On 5/20/06, Collin Winter <[EMAIL PROTECTED]> wrote: > Some things I still have listed as "outstanding issues" for the annotations > PEP: > > 1. You mentioned in one blog post [1] that you wanted to have 'any' > and 'nothing' types. Is this still something you want as built-ins, or > should it be

[Python-3000] Misc type annotation issues

2006-05-20 Thread Collin Winter
Some things I still have listed as "outstanding issues" for the annotations PEP: 1. You mentioned in one blog post [1] that you wanted to have 'any' and 'nothing' types. Is this still something you want as built-ins, or should it be left up to the annotation-interpreting libraries to provide these

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Guido van Rossum
> On 5/19/06, Collin Winter <[EMAIL PROTECTED]> wrote: > > I know the plural of "anecdote" isn't "data"; maybe c.l.p should be > > polled on some of these things? Please don't. It serves no purpose; just like in US politics, you'll always find a pretty much 50/50 split for and against any proposal

Re: [Python-3000] Anti-use-case for type annotations

2006-05-20 Thread Guido van Rossum
On 5/20/06, tomer filiba <[EMAIL PROTECTED]> wrote: > i've been crying about that for quite a long time, but it seems people failed > to see > my point: type checking, which is more easily enforced by type annotations, > is bad. Pleast stop panicking. You don't seem to understand the proposal. >

Re: [Python-3000] Use cases for type annotations?

2006-05-20 Thread Guido van Rossum
On 5/19/06, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > "Steven Bethard" <[EMAIL PROTECTED]> writes: > > > Which brings me to my comment about the current discussion. Can't we > > drop the syntax discussion for a while and have someone motivate it > > with some use-cases first? Read my

Re: [Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

2006-05-20 Thread Guido van Rossum
On 5/19/06, Talin <[EMAIL PROTECTED]> wrote: > Side note: I'm actually in favor of the idea of Python adding > syntactical support for operators that have no "built-in" definition. > The use case would be for classes that define new operators that don't > correspond to the semantics of any existing

Re: [Python-3000] Use cases for type annotations? (WAS: Type parameterization)

2006-05-20 Thread Paul Moore
On 5/20/06, Talin <[EMAIL PROTECTED]> wrote: > Here's a list of use cases that I can think of: [...] Interesting. Can you elaborate one of these into a strawman example, with code, that we can discuss? There are a number of issues I can see, but it's too easy to be vague without a concrete exampl

[Python-3000] Anti-use-case for type annotations

2006-05-20 Thread tomer filiba
i've been crying about that for quite a long time, but it seems people failed to see my point: type checking, which is more easily enforced by type annotations, is bad. and because it will have this nice (and pointless*) syntax, lots of people will start using them everywhere, and make projects li