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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.13.209.5 with SMTP id t5mr27814315ywd.22.1436557435536; Fri, 10 Jul 2015 12:43:55 -0700 (PDT) X-Received: by 10.182.245.130 with SMTP id xo2mr181919obc.30.1436557435502; Fri, 10 Jul 2015 12:43:55 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!e109no112627qge.1!news-out.google.com!t2ni6583igk.0!nntp.google.com!i4no706743ige.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 10 Jul 2015 12:43:55 -0700 (PDT) In-Reply-To: <2215b44f-8a89-47c6-a4c4-52b74d2dac45@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=74.203.194.21; posting-account=bXcJoAoAAAAWI5APBG37o4XwnD4kTuQQ NNTP-Posting-Host: 74.203.194.21 References: <14592326-5070-4663-a864-5684298f3748@googlegroups.com> <004361da-53c4-4ea9-8cc6-38944aa6c7ad@googlegroups.com> <29dd5458-f9ce-4db8-9128-8ab35a9ce5f8@googlegroups.com> <64bc671c-72e5-4924-b703-3b907c69949c@googlegroups.com> <877fq9uj6g.fsf@theworld.com> <65061686-5c8f-433b-9b11-9e228298158e@googlegroups.com> <87k2u96jms.fsf@jester.gateway.sonic.net> <06f8a6f9-d219-4d40-b9ac-8518e93839bd@googlegroups.com> <87y4io63jy.fsf@jester.gateway.sonic.net> <7a29d3e9-d1bd-4f4a-b1a6-14d3e1a83a4d@googlegroups.com> <87mvz36fen.fsf@jester.gateway.sonic.net> <2215b44f-8a89-47c6-a4c4-52b74d2dac45@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: If not Ada, what else... From: Patrick Noffke Injection-Date: Fri, 10 Jul 2015 19:43:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:26751 Date: 2015-07-10T12:43:55-07:00 List-Id: On Friday, July 10, 2015 at 2:10:44 PM UTC-5, David Botton wrote: > > I may be missing something here, but I don't see where Ada's type system > > is that much better than C++'s, > > So in C++ you can create new incompatible types with various ranges, use them for array indexes, true enums? > In C++11 you have enum class which makes an enum its own type. You can still cast it to the class type, but you can't willy-nilly use it as an int as with the old-style enum. This generates an error: enum class Junk : int { One, Two, Three }; int a = Junk::One; // error: cannot convert to int Where this is allowed: int a = (int) Junk::One; But there's nothing to prevent you from using the old style. Even -Wold-style-cast doesn't generate a warning for this: enum Junk { One, Two, Three }; int a = One; (I guess because it's not technically a C cast -- enum really is just an int.) I'm curious -- how would you create incompatible types with different ranges in C++? AFAIK the language itself or the standard library don't provide that. Pat