C strongly typed?

William Thomas Wolfe, 2847 billwolf%hazel.cs.clemson.edu at hubcap.clemson.edu
Mon Mar 12 03:49:31 AEST 1990


>From grano at cs.Helsinki.FI (Kari Gran|):
> P.S. Oh, and I think I forgot 'new's from my previous posting.  In fact
> I'm not so sure about that.. maybe someone could correct this?
>
>>  declare
>>     type apple is integer;   -- could read: type Apple is new Integer;
>>     type orange is integer;  -- could read: type Orange is new Integer;
>>     a : apple;
>>     o : orange;
>>     begin a:= o; end;

   Actually, it would not matter.  By LRM 3.3.1(8), "Two type definitions
   always define two distinct types, even if they are textually identical."

   The "new" mechanism will generally be used when we want to put more 
   constraints on the new type than we had specified for the base type:

      type Weekday is new Day range Monday..Friday;

   This creates the type Weekday, which is distinct from (and incompatible
   with) the type Day.  If we wanted to make them distinct but compatible:

      subtype Weekday is Day range Monday..Friday;

  
   Bill Wolfe, wtwolfe at hubcap.clemson.edu
 



More information about the Comp.lang.c mailing list