News for hackers. Stuff that matters.
Re:Counting Sheeps with Contracts in Python by djoldman on Saturday September 21, 2024 @09:28AM (#41609830)
This isn't meant as a dig, I'm genuinely curious: how is this not simply imposing static typing in python?
Re:Counting Sheeps with Contracts in Python by GrantMoyer on Saturday September 21, 2024 @10:21AM (#41610169)
The pre and post conditions are checked at runtime. Also, typically static type sytems are not expressive enough to statically check more than relatively basic pre and post conditions, even in languages with advanced type systems like Haskell or Scala.
Re:Counting Sheeps with Contracts in Python by Kaethar on Saturday September 21, 2024 @11:37AM (#41610648)
You can have preconditions that check stuff not related to typing (e.g: check that a connection is open before calling the function).
Re:Counting Sheeps with Contracts in Python by maleldil on Saturday September 21, 2024 @03:47PM (#41612221)
It kind of is, but pre/post-conditions can be more than that. Also, I'd consider it bad form to have type signatures (which they have) and runtime checking the same types. The whole point of having static typing is decreasing the need for the latter, but you have to actually run a type checker for it to be useful.