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: Thu, 30 Sep 2004 10:57:07 +0200 Message-ID: <7siml3c62lev$.usczt2y2l19c$.dlg@40tude.net> References: <41547dae$0$91007$39cecf19@news.twtelecom.net> <1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net> <1hl2mizeb27ku$.1f0asrbmb05mi.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de jMazjNUWQWO8Sgb8v8O9lQ4oxp2L+9aRUWUc8Th/NoO9pkcd4= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:4432 Date: 2004-09-30T10:57:07+02:00 List-Id: On Wed, 29 Sep 2004 20:11:46 +0200, Robert Kawulak wrote: >>>> So it allows you to define [] and leaves >>>> you alone with that. It is not the Ada's way (TM). >>> >>> Again I don't see your point here... As to the C++(R) std::vector<>, >>> there >>> is operator [] defined. >> >> An ability to index is just one of many array properties. The whole list >> is very large. > > As well as the list of methods and operators and other members of > std::vector<>... What particular thing are you missing there? Slices (subarrays), ranges (index subsets), aggregates (literal values), looping (automatic iterators), stack allocated arrays ... >> Provocatively, > > ;-P > >> I would claim that an instance of std::vector is not an >> array. For a type to be an array means that the language has some kind of >> array interface defined and thus it can check a type against that >> interface >> to verify whether the type implements the interface. There is no such >> thing >> in C++. > > There is - C arrays. But the definition you wrote shows that you still think > the Ada way (TM) - in C++ (R) built-in types and user-defined types are > treated the same way. Types yes, array types not. That's the point not any type is array type. You are arguing in terms of types, try to go one step up. Array types is a set of types. > Why you think that it is necessary for the core > language to know what is an array and what isn't? In Ada, you can't use > anything else than built-in array exactly as an array. In C++ you can. You get me wrong. I do not argue in favor of built-in arrays. I argue for an ability to have abstract array interfaces either user-defined or built-in, no matter. C++ does not have them and its template mechanism does not help here (*). Ada has them built-in, but does not allow to implement an array by, say, a record type. >> You can claim that the template std::vector defines such array, >> but then what would you do with My_Template_Array designed independently on >> std::vector? It will not be an array then! > > The Ada way, again - who says there can be one and only one type > representing an array? In C++you have C arrays, std::vector<>, > std::valarray<> and even std::string - and all these can be treated in > uniform way as arrays. You mean operator[] here. As I said before, it is not enough. >> BTW, Ada's Unbounded_String is *not* an array, alas. > > Fortunately std::string might be considered as a container, which you may > use like std::vector in most cases. ;-) Can you use it *as* std::vector? No, they are two different *unrelated* types. Same as in Ada, where Unbounded_String can be used *like*, but not *as* String. ------------ (*) The meta-language of C++ templates is untyped. So you cannot define a set of types "Array_Containers" and require its instance (an array) as a template parameter. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de