
Nov. 30, 2021
2:37 a.m.
On Tue, Nov 30, 2021 at 8:19 PM Paul Moore <p.f.moore@gmail.com> wrote:
Also, related to the question Terry raised, IMO it would be useful to have a clear statement on code that *does* use type annotations, but violates them at runtime. To be specific, is the following considered as an error?
def muladd(x: int, y: int, z: int) -> int: ... return x * (y+z) ... muladd(3.1459, 87.33, 2.7e2) 1124.124447
My understanding is that it's precisely as wrong, or not wrong, as this: def add(x, y): """Multiply two numbers""" return x / y To my mind, annotations are machine-readable metadata, with no inherent "correctness" to them (from the language's point of view), other than syntactically. ChrisA