|
|
|
|
|
by kerkeslager
2223 days ago
|
|
> i've used various Python libraries for runtime type-checking (based on `typing` annotations) like `typeguard`. Let's just stop right there, since it's immediately clear you aren't answering the question I asked. You're talking about type checking, not descriptive and expressive power. The topic is whether dynamic types are suitable for domain modeling, not whether dynamic types provide static type checking. We all agree that dynamic types don't provide static type checking. |
|
> Specs/contracts are cool but ultimately don't afford the same kind of descriptive and expressive power that a static type system does.
i understand that as "the ability to describe/enforce the domain's rules".
now, i guess i made a bit of leap, jumping to runtime typechecking. my thinking was that while modelling your domain, you might want to specify that e.g. `width` and `height` must at least be numeric (i know i would!); `typeguard` et al are a concise way of doing that in Python, but have their limitations. so static types can be more "expressive" if the tools i mentioned (generics and function types) are useful for describing your domain model, which i often find to be the case.
looks like i missed the mark there; but in that case, i'm not sure what point you're making with that Square class. it's hard to say what's missing (or not) because there's not a lot there.