On 5/18/06, Paul Moore <[EMAIL PROTECTED]> wrote: > On 5/18/06, Collin Winter <[EMAIL PROTECTED]> wrote: > > In looking through all of Guido's blog posts on the subject -- and all > > the comments on them -- I haven't seen anyone consider the case of > > generators. Assuming that "->" makes assertions only about the > > function's return type, if I were to write a generator with the > > following type, > > > > """def my_range(min: Number, max: Number) -> Number""" > > > > it would blow up because the function returns a generator, not a Number. > > I'd suggest you consider this in analogy with functions returning > functions. Example: > > def foo(n : Number) -> ????: > def bar(): > return 12 > return bar > > What is ????
You seem to have missed the threads [1], [2] where this exact issue was discussed. The current thinking is something like Function(int, int).returns(int). So, reasoning by analogy would point to something like Generator(is_sent=int, yields=int). In my mind, though, since generators -- as opposed to function-returning-functions -- are a sufficiently core part of the language worth their own special syntax (e.g., the yield keyword), there might be interest in continuing this special status in the type annotation syntax. Thanks, Collin Winter [1] - http://mail.python.org/pipermail/python-3000/2006-May/001972.html [2] - http://mail.python.org/pipermail/python-3000/2006-May/002061.html _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
