3 ms·
It's the difference between conversion and casting: Casting, explicit or implicit, throws away type information, and reinterprets the same data in a different
by cbd1984 12y ago
It's the difference between conversion and casting:
Casting, explicit or implicit, throws away type information, and reinterprets the same data in a different way. Data, here, is bytes, or some other low-level representation that makes what the types apply to.
Conversions, explicit or implicit, uses type information to either change data, or prove that no change is needed, in order to use the data a different way.
- imanaccount247 12y agoBut that isn't what we're talking about. Changing a number to a string and using it as a string is exactly as bad as changing a string to a number and using it as a number.
- cbd1984 12y ago> Changing a number to a string and using it as a string is exactly as bad as changing a string to a number and using it as a number. Both of those are examples of strong typing in action.
- imanaccount247 12y agoNo, they are both examples of weak typing in action. Both of those are an error in a strong type system. That's the point.
- cbd1984 12y agoOnly if the strong type system is specified to return errors on those kinds of mismatches, as opposed to using the type information to perform a conversion and give another result which is just as well-defined as an error. That's the point: Strong typing ensures all results are well-defined, as the result of a specification, and it uses type information to do that. Weak typing throws away type information, so it can no longer uphold such specifications.
- imanaccount247 12y agoYour definition is one that you made up though. Most people use the actual definitions of words.