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-Thread: 103376,635cd9622b25ae59 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.maxwell.syr.edu!news-rtr.nyroc.rr.com!news-out.nyroc.rr.com!twister.nyroc.rr.com.POSTED!53ab2750!not-for-mail From: "REH" Newsgroups: comp.lang.ada References: <1146143954.169807.207080@t31g2000cwb.googlegroups.com> <1146148380.102042.119860@y43g2000cwc.googlegroups.com> Subject: Re: Type safety, C++ and code generation X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-RFC2646: Format=Flowed; Response Message-ID: <6E45g.5852$TT.908@twister.nyroc.rr.com> Date: Sun, 30 Apr 2006 15:23:46 GMT NNTP-Posting-Host: 69.205.134.80 X-Complaints-To: abuse@rr.com X-Trace: twister.nyroc.rr.com 1146410626 69.205.134.80 (Sun, 30 Apr 2006 11:23:46 EDT) NNTP-Posting-Date: Sun, 30 Apr 2006 11:23:46 EDT Organization: Road Runner Xref: g2news2.google.com comp.lang.ada:4001 Date: 2006-04-30T15:23:46+00:00 List-Id: wrote in message news:o%35g.64094$_S7.49734@newssvr14.news.prodigy.com... > > "Maciej Sobczak" wrote in message > news:e2qn8t$n13$1@sunnews.cern.ch... >> >> What about making different types really distinct? >> >> typedef ranged_type R1; >> typedef ranged_type R2; >> typedef ranged_type R3; >> >> >> Above, R1 and R2 are *equal* to the compiler, but R3 is distinct from the >> other two. > This example raises the issue of structural equivalence versus > name equivalence. In Ada R1 and R2 would not be > equivalent. > > Ada is designed for name equivalence. Most other languages > are designed for structural equivalence. In this respect, Ada > continues to be just a wee bit more type safe than languages > designed for structural equivalence. > > Richard Riehle C++ does not use structural equivalence (nor does C). It too uses name equivalence. The problem is that typedef does not introduce a new name, but an alias. The only way to introduce a new name is via enum, struct, class, or union. templates also introduce new names, but instantiation with the same set of parameters are of the same name. structs defined with the exact same fields but different names, are different. REH