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!bigfeed.bellsouth.net!bignumb.bellsouth.net!news.bellsouth.net!bignews4.bellsouth.net.POSTED!84c79386!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada References: Subject: Re: Typing in Ada MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: X-Complaints-To: abuse@bellsouth.net X-Abuse-Info: Please forward a copy of all headers for proper handling X-Trace: npbhgpngjbkmjfegdbdpiflmbcekedmfhojhikkbagflhcbojfcehfmhpdpbggoojpeljoalhagcaphljmoefopbncahmocadpckpincdinplbninehpnhldoiampbkliboeogjeejmmdbcbobdfdaecnnfkdeik NNTP-Posting-Date: Mon, 31 May 2004 22:13:46 EDT Organization: BellSouth Internet Group Date: Mon, 31 May 2004 21:14:31 -0500 Xref: controlnews3.google.com comp.lang.ada:973 Date: 2004-05-31T21:14:31-05:00 List-Id: But both examples for C disregard the fact that int, enum, and char can be freely mixed, something that Ada would never allow. "Peter C. Chapin" wrote in message news:Xns94FAA347BFEA8pchapinsovernet@207.106.93.237... > 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 > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada-france.org > http://www.ada-france.org/mailman/listinfo/comp.lang.ada >