DISQUS

Languages of the real and artificial: Three Lefts Make a Right: The Type Declaration Paradox

  • The Dreamer · 4 years ago
    Guido on static typing in Python
    I was just reading the latest brain dump by Guido on 'Optional Static Typing in Python' and various comments on it.

    First impression? I don't like it. The simple reason being that it makes Python much more complex. I know its the same rant again ...
  • Keithb · 3 years ago
    Colour me baffled (does that make me one of the smart people?)

    Of the approaches you present exactly one will definitely prevent the function body being executedwith ill-typed arguments by any client code: assertions.

    Variable names, comments and structured comments will not provent client code asking for gcd(-7.62, 2+i), but they will prompt any human who's read the declaration of gcd to not casually write code that would do that, which seems like a win. This is the way programmers in languages with dynamic typing get used to thinking.

    Of your proposed aproaches exactly one tells the human programmer and the client code a direct lie about gcd(): type declaration. It does not merely "[lose] the information that a and b are non-negative", it asserts the untruth that they can be negative. How is this any sort of benefit?