C strongly typed?
Erland Sommarskog
sommar at enea.se
Sat Mar 10 10:12:04 AEST 1990
Richard O'keefe (ok at goanna.oz.au) writes:
)A Pascal compiler may complain that "o" is uninitialised, but it
)*must* accept the assignment as well-typed. (I tried it.)
True, Pascal is as weakly typed as C.
)Try it in Ada (not checked, as I haven't access to an Ada compiler):
) declare
) subtype apple is integer;
) subtype orange is integer;
) a: apple;
) o: orange := 1;
) begin
) a := o;
) end
)Again, the assignment is well-typed. Why should C be different?
That compiles, I would guess, but not if you declare:
TYPE apple IS NEW integer;
TYPE orange IS NEW integer;
which of course the way to do it.
--
Erland Sommarskog - ENEA Data, Stockholm - sommar at enea.se
More information about the Comp.lang.c
mailing list