comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@alexandria (Jon S Anthony)
Subject: Re: Extending A Generic Signature Package
Date: 1997/03/22
Date: 1997-03-22T00:00:00+00:00	[thread overview]
Message-ID: <JSA.97Mar21200655@alexandria> (raw)
In-Reply-To: 5gkv23INN3rn@thalamus.cis.ohio-state.edu


In article <5guuehINN6iq@thalamus.cis.ohio-state.edu> dgibson@thalamus.cis.ohio-state.edu (david scott gibson) writes:

> Jon S Anthony <jsa@alexandria> 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





  parent reply	other threads:[~1997-03-22  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-17  0:00 Extending A Generic Signature Package david scott gibson
1997-03-18  0:00 ` Tucker Taft
1997-03-18  0:00   ` Alexander V. Konstantinou
1997-03-21  0:00     ` Geert Bosch
1997-03-21  0:00       ` Brian Rogoff
1997-03-22  0:00         ` Robert A Duff
1997-03-21  0:00 ` Jon S Anthony
1997-03-21  0:00   ` david scott gibson
1997-03-22  0:00     ` Robert A Duff
1997-03-22  0:00 ` Jon S Anthony [this message]
1997-03-21  0:00   ` david scott gibson
1997-03-22  0:00     ` Robert A Duff
1997-03-25  0:00 ` Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox