Let's say, we create a reimplementation of C, with the only difference being that types are inferred. Storage classes and modifiers would still need to be given (const, static, restrict etc), and let's restrict our attention to single file C programs for the moment. Could it be done? What are the major impediments?
Some thoughts on what might cause problems with type inference
- structs with the same field name would need to be disambiguated manually
- same for unions with the same field names
casts would probably need a "from" annotation, something like
var i = (uint32_t -> uint64_t) *some_pointer;
These problems would require a bit of user annotation, but shouldn't be too burdensome, is there some killer issue that blows this idea out of the water?
Edit: To clarify, I'm not talking about adding generics or parametric polymorphism, just type inference for existing C types.
Edit 2014: Anyone interested in this concept may want to look into Rust