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 Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!fr.ip.ndsoftware.net!62.253.162.218.MISMATCH!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!newspeer1-win.ntli.net!newsfe4-gui.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng 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> <4232ab3a$0$26547$9b4e6d93@newsread4.arcor-online.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Mon, 14 Mar 2005 14:40:45 GMT NNTP-Posting-Host: 81.100.88.147 X-Complaints-To: http://www.ntlworld.com/netreport X-Trace: newsfe4-gui.ntli.net 1110811245 81.100.88.147 (Mon, 14 Mar 2005 14:40:45 GMT) NNTP-Posting-Date: Mon, 14 Mar 2005 14:40:45 GMT Organization: ntl Cablemodem News Service Xref: g2news1.google.com comp.lang.ada:9361 comp.lang.c++:45549 comp.realtime:1445 comp.software-eng:5010 Date: 2005-03-14T14:40:45+00:00 List-Id: On Sat, 12 Mar 2005 09:42:26 +0100, Georg Bauhaus wrote: > Falk Tannh�user wrote: >> Dr. Adrian Wrigley wrote: >> >>> But what of features not present in either? >> >> [...] >> >>> associative arrays (from Perl) >> >> Wouldn't that be std::map in C++? > > and in Ada 2005, > > Ada.Containers.Hashed_Maps and Ada.Containers.Hashed_Maps I have probably missed a trick in the C++, but I couldn't get std::map code to compile (except in the trivial cases): #include struct compoundindex { int a, b, c; }; int main() { std::map hash; compoundindex fred = { 1, 2, 4 }; hash[fred] = 0.123; } cpptest.cpp: In function `int main()': cpptest.cpp:14: error: `main()::compoundindex' uses local type `main()::compoundindex' (8 more lines of errors here!) (what is the simplest C++ code to get this intent?) -- The Ada associative arrays from the new draft standard are specified as something like: generic type Key_Type is private; type Element_Type is private; with function Hash (Key : Key_Type) return Hash_Type is <>; with function Is_Equal_Key (Left, Right : Key_Type) return Boolean is "="; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Hashed_Maps is... Which clearly won't work unless you can find the three function generic parameters. I don't see how this can be used easily in a generic context. I don't think I am being *that* unreasonable in asking for arrays indexed by arbitrary types, without jumping through hoops :) -- Adrian