4 ms·
> Heck, a function that's int x int -> int could be just about anything. How about string -> int? That's because using types like "int" and "string" is not a r
by golergka 7y ago
> Heck, a function that's int x int -> int could be just about anything. How about string -> int?
That's because using types like "int" and "string" is not a real, valid use of a good type system. Instead, you'd typically have a function type of `newton -> sqMeter -> pascal`, or `username -> accessLevel`. All these types would be implemented through basic int and string types, but declaring them explicitly with very limited conversions inbetween would actually use type system to verify correctness of your code.
- mpweiher 7y agoSo you're going to not have arithmetic or string manipulation?
- codebje 7y agoYou're probably not going to need a separate function for a binary operator.
- tathougies 7y agoNot really. I may have vector length manipulation and address formatting though. But vector lengths are not integers (or natural for that matter) and an address is certainly not a string. Perhaps you could use these primitives to represent these things but we should not confuse representation with equality.
- AgentOrange1234 7y agoYes so much. An integer can represent all sorts of things, so forever programmers have been using integers to represent all sorts of things. If instead of “int age, int size, int color” you have “age_t age, size_t size, color_t color”, and a type system that helps keep these apart, so much confusion can be avoided...
- golergka 7y agoArithmetic of adding up kilograms and meters together is wrong. Arithmetic of adding up kilograms and kilograms together is automatically inherited when you declare a derived type.