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,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Tue, 28 Sep 2004 10:20:45 +0200 Message-ID: <87u4rkhddelw$.1uuoqhfyd2eay$.dlg@40tude.net> References: <41547dae$0$91007$39cecf19@news.twtelecom.net> <1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 0rOocRXUIp5K1tkdnrehaAVLjAp3RfqTLiaWN6me0pTfH2cgQ= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:4312 Date: 2004-09-28T10:20:45+02:00 List-Id: On 27 Sep 2004 21:22:03 -0700, Kevin Cline wrote: > "Dmitry A. Kazakov" wrote in message news:<1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net>... >> On 27 Sep 2004 07:31:44 -0700, Kevin Cline wrote: >> >>> Matthew Heaney wrote in message news:... >>>> kevin.cline@gmail.com (Kevin Cline) writes: >>>> >>>>> One of the most frustrating things I found in Ada programming was the >>>>> inability to make user-defined types work like the built-in types. >>>>> Given >>>>> >>>>> A: array (1..10) of integer; >>>>> >>>>> then the expression A(5) is a modifiable reference to the fifth >>>>> element of A. >>>>> >>>>> After experience with C++ it was amazingly frustrating to learn that >>>>> there was no way I could define My_Container so that I could write: >>>>> >>>>> C: My_Container ; >>>>> >>>>> C(5) := 7; >>>> >>>> Indeed, you cannot do this. In AI-302 (and in Ada.Strings.*), you have to say: >>>> >>>> Replace_Element (C, Index => 5, By => 7); >>> >>> I think this was a major error in the language design. >> >> It was not an error, in the sense that no irreparable damage was done. It >> seems that the issue was just put aside for better times. Ada has a rich >> infrastructure supporting array types and their index types. So to reshape >> Ada's arrays out of abstract "array interfaces" one need to take all that >> presently hard-wired infrastructure with. Note that C++ does not solve the >> problem, because it has no arrays. So it allows you to define [] and leaves >> you alone with that. It is not the Ada's way (TM). > > C++ solves the problem very nicely, it just wasn't solved once and for > all by the language designer or by the standard committee. It's not > necessary for C++ to have a sophisticated built-in array class because > it is relatively easy to build any sort of array you like. ... which won't be an implementation of that sophisticated *non-existing* class. That's the point. > So we have > std::vector and boost::array, and if you need a sparse array or any > other sort you can build that too and they will all work with the > standard algorithms and you can switch out one for another with little > effort. First, that all will be templates, I do not want them, generics are inherently bad. For instance, it is impossible to have generic programming on containers of containers. You cannot have a list of items of "array" types that are different instantiations. Because see above, you have no that common abstract predecessor. That "arrays" are not arrays, we are just fooling ourselves. Secondly it is not checked whether the thing you are implementing *is* an array which *will* work with all that standard algorithms. You never know before you instantiate. Ideologically, it is stone age, not the Ada's way, IMO. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de