3 ms·
You’re right that it’s an issue of typing, but lots of type systems handle this just fine. Even Go’s type system—which everyone loves to hate—let’s you create n
by weberc2 9y ago
You’re right that it’s an issue of typing, but lots of type systems handle this just fine. Even Go’s type system—which everyone loves to hate—let’s you create new types from existing ones (such as a UserID type based on int). This feature is frequently referred to as newtype, and its even present in Python via typing.NewType! This is a bit nicer than the wrapper approach you describe for performance reasons (in practice, wrapping an int in a class will create unnecessary overhead for many languages).