J
Jeremy Yallop
Dik said:In what way does C fail here?
In that the connection between object and type in C is very weak.
Objects are almost typeless: the type of the expression used to access
the object is the important thing. This is particularly apparent in
the case of the objects for which malloc allocates space:
int max(int x, int y) { return x > y ? x : y; }
void *pv = malloc(max(sizeof(double), sizeof(int)));
sin(*(double *)pv = 3.5); /* the object "has" type double */
abs(*(int *)pv = 3); /* the object "has" type int */
Jeremy.