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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: operation can be dispatching in only one type Date: Mon, 23 Nov 2015 16:52:58 +0100 Organization: cbb software GmbH Message-ID: <2vkcf6a2yafd.18hnnbljmlqx1$.dlg@40tude.net> References: <1e4hyjazuvi88.159qsn7u0y067$.dlg@40tude.net> <817c092d-4c49-4b09-a116-6d27d4d20291@googlegroups.com> <127g5diox4xef$.1bc0ja7q2xobo.dlg@40tude.net> <26b461b8-3a2e-4fee-906f-673c7ff22543@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: uuaYi8S0HktMvp6/JW1g+A.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28508 Date: 2015-11-23T16:52:58+01:00 List-Id: On Mon, 23 Nov 2015 06:16:38 -0800 (PST), Serge Robyns wrote: > On Monday, 23 November 2015 14:48:45 UTC+1, Dmitry A. Kazakov wrote: >> On Mon, 23 Nov 2015 05:05:02 -0800 (PST), Serge Robyns wrote: >> >>> On Monday, 23 November 2015 12:29:55 UTC+1, Dmitry A. Kazakov wrote: >>>> On Mon, 23 Nov 2015 02:23:57 -0800 (PST), Serge Robyns wrote: >>>> >>>>> I'm facing an issue with Ada when it comes to use an operation on two >>>>> tagged types. >>>> >>>> You can use tagged types, they cannot be dispatching arguments though. That >>>> is a big difference. >>>> > >> C++ code is broken, always broken, because C++ confuses T and T'Class and >> hence re-dispatches each time and every place (except for ctors). Ada's >> exact equivalent to >> >> void account::update_balance (account_balance& ab, money amount) >> >> is >> >> procedure Update_Balance (X : in out Account; >> AB : in out Account_Balance'Class, ...) > > This one did the trick. I do feel very frustrated with regards to the Ada > idiosyncrasies, if I may say so. Recalls me the "'" notation I had to use > when declaring a part of a constant that was from a parent class. It depends on what you believe is "right." If you programmed C++ in Ada you would indeed face difficulties, and conversely. But again C++ is inconsistent in its treatment of specific and class-wide types. Ada merely requires you to specify the exact type of the operation's argument, that is. > I'm wondering the best way to "learn" these without falling asleep while > reading for the 10th time basic programming stuff and then missing that > one important comment in the text. Regarding OO features, the best way is start thinking of it in terms of types rather than of [untyped] data structures and procedures. You will better understand both Ada and C++: class = set of types (closed upon inheritance) class-wide type = the closure of the class specific type = member of the class -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de