syntax difference

Rick Johnson rantingrickjohnson at gmail.com
Sun Jun 17 19:30:53 EDT 2018


On Sunday, June 17, 2018 at 2:07:40 PM UTC-5, Jim Lee wrote:

> IMHO, trying to shoehorn static type checking on top of a dynamically
> typed language shows that the wrong language was chosen for the job.

Exactly.

I'm not against the idea of Python growing a new feature.
Features are great. My objection is concerned merely with
the "how" it is implemented, not the "why" it was
implemented.

"Type-hint comments" would allow:

 (1) those who need them, to use them.

 (2) those who don't care about them, to totally ignore
     them.

 (3) and those who utterly *HATE* them, to write a simply
     little function which will strip them from any and all
     source code they might be forced to maintain.

Personally, i would never put type-hints in my Python code.
I write a large portion of my overall code in Python
specifically because i do not wish to be distracted by type
declarations.

Of course, regardless of how much i try to avoid type-hints,
the problem will come, when one day in the future, i am
forced to maintain another Python programmer's code that is
littered with these declarations. And removing them won't be
easy.

But that's the real danger of this feature. The Python
community will not see the real effect of type-hints (at
least, as they are currently implemented) for a long time.
But as more and more type-hints are spread in the wild, more
and more people, and more and more organizations, are going
to look for "cleaner language" to solve their R&D and
general purpose high-level problems.

What's the point of eye-ball-parsing through miles of type-
hints which demand all the burdens of static typing whilst
giving none of the real benefits. The Python interpreter
ignores these hints. But as programmers -- as, human beings,
and not machines! -- ignoring the syntactical noise of type-
hints will be impossible.

So either the Python devs need to release a
"3ToTypeHintFree.py", or they need to re-implement this so-
called feature as a special class of comment. And here is an
example of how that might be done, using Steven's example
from above:



    ## Steven's Example ##
    #(Current implementation of type-hints)
    py> def func(x: float) -> list:
            """Ello, ime-uh lit-al doc-string, yes i am."""
    ...     pass




    ## Prposed solution v1 ##
    py> def func(x):
            """Ello, ime-uh lit-al doc-string, yes i am."""
            # x:float -> list
    ...     pass




More information about the Python-list mailing list