4 ms·
One of the unusual things in this early version of C is that "int" can be used for any word-sized value, including pointers. The type system was very loose.
by ufo 6y ago
One of the unusual things in this early version of C is that "int" can be used for any word-sized value, including pointers. The type system was very loose.
- Blikkentrekker 6y ago> types of the function parameters are not checked, anything can be passed to any function Still a better type system than Twilight.
- Turing_Machine 6y agoEven back then this was considered poor practice, however. The first edition of K&R had a subsection entitled "Pointers are Not Integers" (I don't know if that's still in modern editions).
- rbanffy 6y agoNow I want a float to access individual bits.
- ufo 6y agoThe interesting thing for me is that a variable without a type annotation could potentially store anything. It kind of explains why the language used "int" as the default type of variables declared without a type annotation.
- LukeShu 6y agoIt looks to me like that section was removed in the 2nd edition. Some sections moved around, so maybe I'm just looking in the wrong place, but it's not nestled between "5.5 Character Pointers and Functions" and "5.7 Multi-Dimensional Arrays" like it is in the 1st edition.