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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 19 Apr 2014 11:17:22 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Redispatching References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> <1aa804jg9qq4o$.wdiq33yo621l.dlg@40tude.net> <1w6eh0aiksmdh$.1h16p7y0b8c6h.dlg@40tude.net> <17twpp4p8u7o$.1idvzaaio4f3t$.dlg@40tude.net> <1wjmcbk375lzk.6o7dpqcp3va3.dlg@40tude.net> <8079p8bcukba.za9f3g3z0426$.dlg@40tude.net> In-Reply-To: <8079p8bcukba.za9f3g3z0426$.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <53523f22$0$6698$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 19 Apr 2014 11:17:22 CEST NNTP-Posting-Host: c8c76385.newsspool2.arcor-online.net X-Trace: DXC=WCi=1AKVhj]aAeROF2PWMQA9EHlD;3YcR4Fo<]lROoRQ8kFZkSPCY\c7>ejVX6@K52X0ST X-Complaints-To: usenet-abuse@arcor.de Xref: news.eternal-september.org comp.lang.ada:19407 Date: 2014-04-19T11:17:22+02:00 List-Id: 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, and it permits deferring any type checking to run-time, should programmers have reason to do so. If you think this is improper design, why not outline an algorithm that transfers any such program into one that demonstrably dispenses with downward conversions. > If Ada supported classes of by-copy types, then conversion to S or T'Class > would produce a new object. But the type semantics would remain same. In view of the above example, absent an isomorphic program transformation as requested, by-copy types will require changing the semantics of Ada.