comp.lang.ada
 help / color / mirror / Atom feed
From: "REH" <me@you.com>
Subject: Re: Type safety, C++ and code generation
Date: Sun, 30 Apr 2006 15:23:46 GMT
Date: 2006-04-30T15:23:46+00:00	[thread overview]
Message-ID: <6E45g.5852$TT.908@twister.nyroc.rr.com> (raw)
In-Reply-To: o%35g.64094$_S7.49734@newssvr14.news.prodigy.com


<adaworks@sbcglobal.net> wrote in message 
news:o%35g.64094$_S7.49734@newssvr14.news.prodigy.com...
>
> "Maciej Sobczak" <no.spam@no.spam.com> wrote in message 
> news:e2qn8t$n13$1@sunnews.cern.ch...
>>
>> What about making different types really distinct?
>>
>> typedef ranged_type<int, 0, 100> R1;
>> typedef ranged_type<int, 0, 100> R2;
>> typedef ranged_type<int, 0, 101> 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





  reply	other threads:[~2006-04-30 15:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-27 10:35 Type safety, C++ and code generation Maciej Sobczak
2006-04-27 13:19 ` REH
2006-04-27 14:08   ` Maciej Sobczak
2006-04-27 14:33     ` REH
2006-04-27 15:16       ` Maciej Sobczak
2006-04-27 15:39         ` Georg Bauhaus
2006-04-28  5:57           ` Maciej Sobczak
2006-04-28 12:16             ` Georg Bauhaus
2006-04-28 12:37               ` brian.b.mcguinness
2006-04-28 17:04                 ` Georg Bauhaus
2006-04-28 18:50                 ` Jeffrey R. Carter
2006-04-28 19:07                   ` Randy Brukardt
2006-04-28 19:46                     ` Robert A Duff
2006-04-28 19:55                   ` Dmitry A. Kazakov
2006-04-29 21:28               ` Florian Weimer
2006-04-27 16:05         ` REH
2006-04-28  6:17           ` Maciej Sobczak
2006-04-30 14:40         ` adaworks
2006-04-30 15:23           ` REH [this message]
2006-04-30 18:14         ` Martin Krischik
2006-05-02  6:27           ` Maciej Sobczak
2006-05-02 13:33             ` REH
2006-05-02 15:05               ` Maciej Sobczak
2006-05-02 15:54                 ` REH
2006-05-02 16:50               ` Martin Krischik
2006-05-02 19:50                 ` REH
2006-04-27 14:47     ` REH
2006-04-27 15:10     ` REH
2006-04-28  6:22       ` Maciej Sobczak
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox