3 ms·
Yes, you're right, it should be an integer comparison check ultimately. > TypeScript essentially does that, except that the tags are not going to be optimized
by hopia 7y ago
Yes, you're right, it should be an integer comparison check ultimately.
> TypeScript essentially does that, except that the tags are not going to be optimized by the compiler
What do you mean by this? Typescript erases type information during compilation. So you would not be able to emulate pattern matching against types on TS. Or you could if you manually added some common tag to every single data type like interface.
Or are you talking about just compile-time type checking on TS?
- mixedCase 7y ago> Or you could if you manually added some common tag to every single data type like interface. This is how you emulate them, I took it for granted and neglected to explicitly mention this is a moderately popular convention in TypeScript (those are the tags I referred to). fp-ts for example uses it all over the place. With this the end result is essentially the same with compile-time type-safety for everything, and compiled down to an untyped binary or an untyped JS blob.