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,FREEMAIL_FROM, T_FILL_THIS_FORM_SHORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.19.41 with SMTP id b41mr24523378ioj.5.1448274237512; Mon, 23 Nov 2015 02:23:57 -0800 (PST) X-Received: by 10.183.3.106 with SMTP id bv10mr288115obd.17.1448274237483; Mon, 23 Nov 2015 02:23:57 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!mv3no573775igc.0!news-out.google.com!f6ni10954igq.0!nntp.google.com!mv3no573771igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 23 Nov 2015 02:23:57 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.107.233.114; posting-account=6m7axgkAAADBKh082FfZLdYsJ24CXYi5 NNTP-Posting-Host: 94.107.233.114 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: operation can be dispatching in only one type From: Serge Robyns Injection-Date: Mon, 23 Nov 2015 10:23:57 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:28500 Date: 2015-11-23T02:23:57-08:00 List-Id: Guys, I'm facing an issue with Ada when it comes to use an operation on two tagge= d types. It isn't a road blocker and I've found my way around and are not = using tagged types for these anymore. I've now a function that computes th= e total balance every time. Another option is to pass the id and then sear= ch the map. However in C++ it does work as I expected. Let's say I've the following tagged types. type T_Balance is tagged record Id : T_Balance_Id; Name : T_Balance_Name; Balance : T_Amount; end record; package Balance_Map is new Ada.Containers.Ordered_Maps (Key_Type =3D> T_Balance_Id, Element_Type =3D> T_Balance); type T_Account is tagged record Name : T_Account_Name; Total_Balance : T_Money; Balances : Balance_Map.Map; end record; And I want to have an operation increasing a balance and the total in the a= ccount. The following declaration is refused: procedure Update_Balance (Self : in out T_Account; AB : in out T_Balance; Amount : in T_Money); My hope was that it gets dispatched to the right operation on Self which in= turns will call the right operation on AB. But the compiler seems not to = agree. in C++: class account { public: account_id id; account_name name; money total_balance; balance_list balances; account(); virtual ~account(); void update_balance (account_balance& ab, money amount); }; void account::update_balance (account_balance& ab, money amount) { ab.update_balance(amount); total_balance.amount +=3D amount; }