C strongly typed?

Mike Harrison mph at lion.inmos.co.uk
Fri Mar 9 20:47:48 AEST 1990


In article <2963 at goanna.oz.au> ok at goanna.oz.au (Richard O'keefe) writes:
>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?

Yes, but instead try:

	declare
	    type APPLE  is new INTEGER;
	    type ORANGE is new INTEGER;
	    A: APPLE;
	    O: ORANGE := 1;
	begin
	    A := O;
	end

This assignment IS illegal, though you could write:


	    A := APPLE(O);

which performs an explicit type conversion.


Mike,


Michael P. Harrison - Software Group - Inmos Ltd. UK.
-----------------------------------------------------------
UK : mph at inmos.co.uk             with STANDARD_DISCLAIMERS;
US : mph at inmos.com               use  STANDARD_DISCLAIMERS;



More information about the Comp.lang.c mailing list