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: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Redispatching Date: Sat, 19 Apr 2014 12:58:05 +0200 Organization: cbb software GmbH Message-ID: <1ucv8wkigp0u3.e80q74aojdwf.dlg@40tude.net> References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> <1w6eh0aiksmdh$.1h16p7y0b8c6h.dlg@40tude.net> <17twpp4p8u7o$.1idvzaaio4f3t$.dlg@40tude.net> <1wjmcbk375lzk.6o7dpqcp3va3.dlg@40tude.net> <8079p8bcukba.za9f3g3z0426$.dlg@40tude.net> <53523f22$0$6698$9b4e6d93@newsspool2.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: AuYlnUSfTZrfhAkRjyySpQ.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 X-Original-Bytes: 3313 Xref: number.nntp.dca.giganews.com comp.lang.ada:185846 Date: 2014-04-19T12:58:05+02:00 List-Id: On Sat, 19 Apr 2014 11:17:22 +0200, Georg Bauhaus wrote: > On 18/04/14 22:51, Dmitry A. Kazakov wrote: > >> Consider this set of declarations: >> >> type T is ...; >> procedure Bar (X : T); >> >> type S is new T ...; >> procedure Foo (X : S); >> >> Now the following is illegal: >> >> procedure Bar (X : T) is >> begin >> X.Foo; -- Compile error >> end Bar; >> >> X in Bar is of the type T and of no other type. >> >> You can convert X using so-called "view-conversion" to an object of another >> type, e.g. S or T'Class. This conversion is a type conversion. Yes, it has >> certain properties when X is tagged (and thus by-reference), such as >> reusing the old object for the new one. These properties are irrelevant to >> the type semantics though. You get an object of a different type. > > Actually, in Ada, you will predictably get the object that is passed > for X, which "is" of its type. (As usual, the discussion hinges on > the meaning of "is".) This provides the programmer with more semantic > possibilities: > > procedure Bar (X : T) is > begin > S(T'Class(X)).Foo; -- No compile error > end Bar; > > This type conversion (downwards) is legal, So would an instantiation of Unchecked_Conversion. > If you think this is improper design, Yes I do. You should abstain design of this kind as much as you would ones using Unchecked_Conversion. > why not outline an algorithm that transfers any > such program into one that demonstrably dispenses with downward conversions. Easily. The algorithm is. Type: $ rm -f bar.adb then take a cup of coffee and review your design. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de