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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!nntp.abs.net!attws2!att542!ip.att.net!newsfeed3.global.lmco.com!svlnews.lmms.lmco.com!not-for-mail From: "REH" Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Fri, 11 Mar 2005 14:01:22 -0500 Organization: Earth Message-ID: References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <42309456$1@news.broadpark.no> NNTP-Posting-Host: 158.187.64.144 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:9156 comp.lang.c++:45204 comp.realtime:1295 comp.software-eng:4863 Date: 2005-03-11T14:01:22-05:00 List-Id: "Dr. Adrian Wrigley" wrote in message news:pan.2005.03.11.18.01.45.684764@linuxchip.demon.co.uk.uk.uk... > > C++ features I would to have in Ada: > > * Implicit instantiation. Yeah, I know, it can be unsafe, but that is > > one thing I really like about C++: the ability to automate repetitive > > things. > > Sometimes useful but is it more than "syntactic sugar"? > No, probably not but unlike a lot of my colleagues, I like syntactic sugar. That's why I love being able to overload operators in both languages. I can add to the language, and make my new constructs look like they are part of the language. > >* reference (in out) types in functions (without resorting to > > access types) > > > * meta-templates. very neat stuff. ugly, but neat. > > I think I prefer Ada generics. I have yet to see how Meta-templates > really contribute to a program design. The reason I prefer template (their power, not looks) is their ability to "store" information using the type system. For example, recently on a (personal) project, I had a set of object I wanted to be able to act upon (like std::foreach does) and filter for various criteria. Using templates I created a function to traverse the objects. This function takes two template parameters, the operation to be perfomed, and the filter. I have template classes for filters and operators for the boolean operators to combine and build more advanced filters on-the-fly without creating functors each time. Something like: traverse_objects(objects, operation, filter1(stuff) && filter2(other-stuff) || !filter3()); This has to be done with templates and class types because the boolean operations can't be done now, but "deferred" until called by operation. As an example, this is a simplicist version of the "and" filter: template struct and_filter { and_filter(const A& a, const B& b) : m_a(a), m_b(b) {} bool operator() (Object& o) {return m_a(o) && m_b(o);} A m_a; B m_b; }; template inline and_filter operator&& (const A& a, const B& b) { return and_filter(a, b); } I know its less safe, but I like that I can use "anything" for the template parameters that "fit" the syntax (i.e., using functions or class objects that have the () operator defined). > Named parameter association. Proper parameter modes > "out" and "in out" modes I would love have named parameters too. That way I would not have to "agonize" over the "priority" of my default parameters (i.e., if there are 10 and I have to change the 10th from its default, I have to define the first 9). > > clarity over arrays. C++ gives you choice of pointers > C arrays, vectors. This is one example of where the > 'C' facilities were too limited, and C++ added > alternatives, rather fhan fixing what existed in C. > (and char *, char arrays, string etc) Yes, arrays are first-class objects! > > Strong(er) typing, better enumerations, fixed point types, > modular types *and* non-modular types. Basic type attributes. I love that Ada enumeration don't pollute the global namespace and allow fully qualified names. I wish I could do enum_name::element in C++ without wrapping the enum declaration in a namespace. > > More robust, more readable, less terse syntax, particularly > for complex templates (really!) Completely agree!! > associative arrays (from Perl) I assume you want more than that offered by std::map?