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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ab1d177a5a26577d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-out.readnews.com!postnews7.readnews.com!not-for-mail Date: Thu, 17 Feb 2011 15:11:58 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What's wrong with C++? References: <1ee1a434-4048-48f6-9f5e-d8126bebb808@r19g2000prm.googlegroups.com> <4D5C1824.3020509@obry.net> <21443638-5ec6-49d4-aafe-6fbc1e59daba@r19g2000prm.googlegroups.com> <87d2371e-af91-4d6a-8d5b-3ddb972d84fd@k17g2000pre.googlegroups.com> <87zkpuze5e.fsf@ludovic-brenta.org> <4d5d791f$0$17330$882e7ee2@usenet-news.net> <87vd0izba1.fsf@ludovic-brenta.org> In-Reply-To: <87vd0izba1.fsf@ludovic-brenta.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4d5d8112$0$17330$882e7ee2@usenet-news.net> NNTP-Posting-Host: cc555866.usenet-news.net X-Trace: DXC=jC;RQC3?BJ\<]\aXQFZ3T]GPM]WmX0AG3X_jU_iEKWiPgeB1UVjKk:Lk^BNQcR12TN^Bg7^:KNd2lZeh5\Kl On 2/17/2011 2:55 PM, Ludovic Brenta wrote: > Hyman Rosen writes: >> And what does it mean for something to be >> "really an integer"? > > Simple: integers have arithmetic, enumeration values don't. C and C++ enumerations don't have arithmetic. They do convert automatically to integers, but they don't automatically convert back. >> Ada 'Pos and 'Val attributes certainly give the illusion that Ada >> enumerators are integers too! > > If you mean to say that Ada provides features for unsafe programming, Not at all, merely that it's easy within the language to convert back and forth between enumerations and integers. Nothing unsafe about it. > Now try this and see your "illusion" shattered by reality: > type E is (A, B, C); > B : E := E'Val (E'Pos (A) + E'Pos (C)); -- Constraint_Error What illusion? I certainly know that Ada checks and C doesn't! Oh, and don't Ada implementers go insane because enumerations are supposed to provide the illusion of being consecutive even in the face of representation clauses which give them arbitrary underlying values? Also, I don't know if you did this intentionally or not, but you redefine the name B as a variable when it is already an enumeration literal. Do I recall correctly that this works because enumeration literals are "really" functions returning their value, and functions can be overloaded?