From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1901f265c928a511 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsread.com!newsstand.newsread.com!POSTED.newshog.newsread.com!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Typing in Ada From: "Peter C. Chapin" References: Organization: Kelsey Mountain Software Message-ID: User-Agent: Xnews/5.04.25 Date: Mon, 31 May 2004 20:03:05 GMT NNTP-Posting-Host: 216.114.178.238 X-Complaints-To: Abuse Role , We Care X-Trace: newshog.newsread.com 1086033785 216.114.178.238 (Mon, 31 May 2004 16:03:05 EDT) NNTP-Posting-Date: Mon, 31 May 2004 16:03:05 EDT Xref: controlnews3.google.com comp.lang.ada:959 Date: 2004-05-31T20:03:05+00:00 List-Id: Jeffrey Carter wrote in news:mxJuc.18113$be.10152 @newsread2.news.pas.earthlink.net: > procedure Strongly_Typed is > type I1 is new Integer; > type I2 is new Integer; > type I3 is range -100 .. 100; [snip] > > int main () { /* I cannot call this Strongly_Typed */ > typedef int I1; > typedef int I2; > typedef short I3; This isn't an entirely fair comparison because in C, typedef doesn't introduce a new type it simply creates a new name for an existing type. In Ada, it would be more similar to using a subtype, perhaps. Something like subtype I1 is Integer; In any event to create a new type in C you need to introduce a structure. In fact, different structures do have different types: typedef struct { int x; } A; typedef struct { int x; } B; int main() { A a; B b; a = b; // Error. A and B are different types. ... I'm not sure if there is a formal definition of strong typing or not. I've always thought that it had to do with the property of every expression and variable having a well defined type. If so, that is as true of C as it is of Ada (in some ways its even more true of C because in C literal numbers have specific types... there is no "universal integer" type used, for example, for integer literals). The real difference is that C does a bunch of automatic type conversions and, furthermore, normally performs these conversions without checking if the converted value will fit into the target type. I'm not sure that's a strong typing issue, however. Peter