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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1cf653444208df72 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-08 10:47:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!feed.textport.net!out.nntp.be!propagator-SanJose!news-in-sanjose!in.nntp.be!easynews!cyclone2.usenetserver.com!usenetserver.com!news01.optonline.net!news02.optonline.net.POSTED!not-for-mail From: "Mike Mohr" Newsgroups: comp.lang.ada References: <9pgr68$7pu1@news.cis.okstate.edu> <9phnic$9g5$1@nh.pace.co.uk> <5fkv7.134136$w7.19988807@news02.optonline.net> <9pski60j31@drn.newsguy.com> Subject: Re: ada vs. cpp X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Mon, 08 Oct 2001 17:47:53 GMT NNTP-Posting-Host: 24.188.177.13 X-Trace: news02.optonline.net 1002563273 24.188.177.13 (Mon, 08 Oct 2001 13:47:53 EDT) NNTP-Posting-Date: Mon, 08 Oct 2001 13:47:53 EDT Organization: Optimum Online Xref: archiver1.google.com comp.lang.ada:13950 Date: 2001-10-08T17:47:53+00:00 List-Id: "Robert*@" wrote in message news:9pski60j31@drn.newsguy.com... > In article , "Mike says... > > > > > >> > >> subtype Code is Positive range 1 .. 4; > >> subtype Arg is Positive range 6 .. 8; > >> > >> V2 : constant String := V1 (Arg) & '-' & V1 (Code); > > >const string V1 = "0123/zzz"; > >const string V2 = V1.substr(0, 4) + "-" + V1.substr(5,7); > > > >Even though your efforts to describe something easy for Ada > >and hard for C++ have failed, you should know that I can play > >these C++-strings-can-do-this-in-2-lines-and-Ada-can't > >games as well. > > > > The difference is that in Ada the range itself is a separate type declaration. > So, one can change the range type in one place and have it propgate all > over. With your attempt, you hardcoded the range using magic numbers in > the variable declaration itself, so if the same range is to be used > somewhere else in the code, or in different variable declaration, you > need to type it there too manually. struct range { int first; int last; }; range code = { 0, 4 }; range arg = { 5, 7 }; const string V2 = V1.substr(code.first, code.last) + "-" + V1.substr(arg.first,srg.last); > There is nothing equivelant in C++ to declaring a new type integer > with restricted range. It is simply not in the C++ language. I have shown you I can get the same functionality without breaking a sweat. What kind of support for string transformations does Ada have? How does it stack up against ? random_shuffle(), next_permutation(), rotate(), etc... If you want to play my-language-can-do-this-in-1-line-and-yours-cant games, I'll be happy to oblige. Since we are discussing orthogonal language features which constitute string defects if not present, how do I explicitly pass Ada strings by value or reference?