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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,acb50cdf95d3e13c X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: Extending A Generic Signature Package Date: 1997/03/22 Message-ID: #1/1 X-Deja-AN: 227397327 Distribution: world References: <5gkv23INN3rn@thalamus.cis.ohio-state.edu> 16: 26:40 -0500 Organization: PSI Public Usenet Link Newsgroups: comp.lang.ada Date: 1997-03-22T00:00:00+00:00 List-Id: In article <5guuehINN6iq@thalamus.cis.ohio-state.edu> dgibson@thalamus.cis.ohio-state.edu (david scott gibson) writes: > Jon S Anthony wrote: > > >Just to be clear, "pointers" are only indirectly relevant to > >dispatching. The key is passing a class wide type argument(s) to a > >controlling operand(s) of a primitive operation. For example, there > >is no need of a pointer in your above example: > > > > declare > > X : Base'Class := Get_Object; > > begin > > Op1(X); > > end; > > So in this case it's clear to us and the compiler what specific type > derived from Base Get_Object returns. No, the _specific_ type is unknown until runtime. But, whatever it is, it will be in Base'Class. > It may or may not be an access type. In this particular case (as written) it cannot be an access type as no access type is legal as a specific type of any class-wide type (only tagged types are so legal). > If an access type, Op1 could have an access parameter formal > and still dispatch. Yes, if there were an access type to Base'Class being returned (which as it is written can't be), Op1 could have a controlling parameter of an annonymous access to some specific type in Base'Class and it would still dispatch as you would expect. > However, Get_Object must return a tagged type and thus the value > returned must be returned by reference in either case, right? Ah. This is something that many people trip over: an access object (or "pointer") is not the same thing as an object that happens to be passed by reference. Also, tagged types are not necessarily return by reference types (_limited_ tagged types are: see 6.5(11)). > So whether explicit or not X, the value of X must be a pointer > to some object. Is that right? No, that's not correct. If X is not explicitly an access object, its value is not a "pointer" to some object. > If Get_Object doesn't return an acces type and we don't use > Unchecked_Access or aliased variables anywhere in the program, does > Ada guarantee that the object to which X points cannot be aliased? Depends on what you mean by "aliased". The most typical interpretation would be that it means referenced by more than one object. For this case, Ada alone does not offer any guarantee. /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com