Hacker News
points by __MatrixMan__ 2 days ago | 0 comments
PSA: you can typically declare different types of string so that your type system objects to mixing data of different types even though deep down we know they're both strings.
[–] BoppreH 2 days ago
If you mean type aliases, that's a good idea within a single codebase, but the distinction between different types of strings doesn't survive serialization so it wouldn't have prevented this error. What they need is a way to signal errors out-of-band, like Result<T> or exceptions.
[–] __MatrixMan__ 2 days ago
In python, aliases are separate from typing.NewType, but you're right: it's only enforced within a codebase and then only if the dev cares to run the typechecker.

So yeah, I guess it either needs to happen at runtime, or we just do signaling and user data on separate file descriptors.

[–] Normal_gaussian 2 days ago
This is presuming that the type system is nomitive rather than structural and there is not serialisation/deserialisation or type refinement occurring. A structural difference is much more preferable.