2 ms·
If by "strict typing" you mean strongly typed then you are factually incorrect. By virtue of casting C is weakly typed, as is Java, C++ et al. If your understa
by leksak 11y ago
If by "strict typing" you mean strongly typed then you are factually incorrect. By virtue of casting C is weakly typed, as is Java, C++ et al.
If your understanding of strict typing is statically typed, i.e. that types are checked at compile time then C still has some flaws as you could write a whole slew of C that is "typeless" using void * although that would be terribly misguided.
I understand your intent, but I dislike the ambiguity of the phrasing.
- JDevlieghere 11y agoAs Dennis Ritchie once said "C is a strongly typed, weakly checked language."
- masklinn 11y ago> By virtue of casting C is weakly typed, as is Java, C++ et al. Java's casts are dynamically checked, memory-safe and only work through the inheritance hierarchy, if you try to cast to an invalid type you'll get an error. Putting it in the same class as a C-style cast makes your usage of "weakly typed" as meaningless as it ever is. For C++ — ignoring C-style casts — it depends which cast you use, dynamic_cast requires RTTI but IIRC it offers the same guarantees as Java's cast; static_cast should check that the types are related and the conversion is valid at compile-time, reinterpret_cast is the "weakly typed" one (essentially a simpler version of a C-style cast). > I understand your intent, but I dislike the ambiguity of the phrasing. Yet you use the expressions "strongly typed" and "weakly typed"?
- Rusky 11y agoThere's also a valid distinction to be made between weak typing through implicit conversions and weak typing through reinterpret_cast. C++ has both unfortunately, but the second one is often necessary for a low-level language.