Hacker News new | past | comments | ask | show | jobs | submit login

So you want strong typing, but then are to lazy to properly type your function definitions?



I want a typing system with a good inference that doesn’t require me to type each and every variable, just like in any good statically-typed language like OCaml or Typescript. Strong typing and explicit typing are two very different things.


no need to explicitly write the type if you have type inference:

  > # fun x -> x + 1;;
  > - : int -> int = <fun>
  >


1) the code you wrote isn’t Python.

2) inferring the type is int isn’t guaranteed to be correct in this case


It's guaranteed to be correct if you use different operators for ints and floats, which is what at least some ML dialects (notably, OCaml) do precisely so that types can be inferred from usage.

That's the downside of operator overloading - since it relies on types to resolve, they need to be known and can't be inferred.


I was merely giving an example that strong typing has nothing to do with having to write the types. (and, obviously, the inferred type (int -> int) is correct. )


Only if reveal_type only accepts an int. Just because the default value of i is 0 doesn't mean anything about what could be passed in.


not my fault python is broken.


> and, obviously, the inferred type (int -> int) is correct.

No it’s not. It’s Optional[int] -> int at minimum. There are other completely valid signatures beyond that too.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: