C strongly typed?

John W. Baugh Jr. jwb at cepmax.ncsu.EDU
Fri Mar 9 00:24:33 AEST 1990


In article <2963 at goanna.oz.au>, ok at goanna.oz.au (Richard O'keefe) writes:
> In article <849 at enea.se>, sommar at enea.se (Erland Sommarskog) writes:
> > C strongly typed?  If I write something like: (I don't speak C
> > so the syntax is probably bogus.)
> > [some C code]
> > Will a "modern" compiler object?
> 
> No, of course not.  Try it in Pascal:
> [some Pascal code]
> A Pascal compiler may complain that "o" is uninitialised, but it
> *must* accept the assignment as well-typed.  (I tried it.)

I think the issue here is "type equivalence," i.e., the relation that
determines whether or not two types are compatible, assignable, etc.
Equivalence mechanisms range from structural equivalence (fairly
loose) to name equivalence (tight).  Although the original Pascal
definition was silent on the issue of type equivalence, I was under
the impression that the recent ISO/ANSI Pascal standard defined
equivalence based on name.

For example, giving the definitions:

  type
    t1 = array[1..3] of boolean;
    t2 = array[1..3] of boolean;
  var
    v1 : t1;
    v2 : t2;
   
the types of v1 and v2 are distinct under name equivalence, but equal
under structural equivalence.

John Baugh



More information about the Comp.lang.c mailing list