[Python-ideas] PEP 484 (Type Hints) -- first draft round

Stephen Hansen me+python at ixokai.io
Tue Jan 20 07:35:45 CET 2015


On Mon, Jan 19, 2015 at 10:22 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:

> Stephen Hansen wrote:
>
>> Type hinting is already making function definitions verbose enough as it
>> is. The very idea that we'd have both ":" and "::" in the language and that
>> somehow this isn't ambiguous is completely obscene to me.
>>
>
> If we were to *really* use :: the way Haskell uses it,
> then the type information wouldn't be in the function
> header. It would be on a separate line, much like a
> decorator:
>
>   quack :: lambda float, int: AnimalSound
>   def quack(volume, num_times):
>      ...
>
>
That's still verbose, its simply vertically verbose. We have decorators for
adding information in the vertical space. Again the duplication of effect
seems crazy to me:

@foo
bar :: something, baz: something
def bar(baz):
    pass

This reads like a terrible joke. You have : and :: and there's absolutely
nothing intuitive or even suggestive about one verses the other, they're
almost identical after all. Then you have decorators and ... whatever you
call that line? What's the difference?

We already have an approved syntax for tagging information to function
arguments and to signify return type. We shouldn't have two.

Almost no one uses function annotations, in eight years almost no one has
come up with a good general use-case for them besides type hinting, which
they were always meant for. Let's use them.

I do wish you could annotate assignment statements (say, a: int = 5) as I
hate the comment feature fiercely, but we can't all have everything.

Worst case scenario, someone wants to use the annotations for something
else, doesn't get to use mypy or other competing tool on that file. We
don't need two syntaxes for this problem space.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150119/5f06c168/attachment.html>


More information about the Python-ideas mailing list