C strongly typed?

Charles Hannum CMH117 at psuvm.psu.edu
Sat Mar 10 15:56:34 AEST 1990


In article <862 at enea.se>, sommar at enea.se (Erland Sommarskog) says:
>
>Well, apparently I am allowed to mix apples and oranges. If I have
>two types of data that both happens to be represented by integers,
>but have no logical connection what so ever I cannot apparently
>express that in C. And consequently I cannot take help from the
>compiler to catch inadvertent mixups in for instance procedure calls.


Well, yes, the following does compile with no problems:

  typedef enum {
      SKIN, CORE
  }   apple;

  typedef enum {
      PEEL, SEED
  }   orange;

  apple  grannysmith;
  orange tangerine;

  int main(void) {
      grannysmith = tangerine;
  }


But if I may ask, what's your point?  Anyone programmer with half a brain
would know that a Granny Smith isn't equivalent to a tangerine.

I like C precisely because it DOESN'T hold my hand.


Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117 at psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h at psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."



More information about the Comp.lang.c mailing list