comp.lang.ada
 help / color / mirror / Atom feed
From: "Troy Noble" <tmnoble@rmi.net>
Subject: Re: Ada tagged types not as powerful as C++ for dispatching???
Date: 1997/08/18
Date: 1997-08-18T00:00:00+00:00	[thread overview]
Message-ID: <01bcab6a$f2061820$92165da6@csp3610x> (raw)
In-Reply-To: JSA.97Aug16191349@alexandria.organon.com


Jon,

I'm using GNAT 3.09 on Linux and on Win32.  I got the same
results in both places.

The fact that you got it to work caused me to go back and
take another look.  What I uncovered may or may not be a
bug in GNAT, but I'm not sure I know Ada95 well enough
to make that call.  See what you think...

The only difference between what you tried and what I tried
is that in my message on this newsgroup I put the definition
of Circle_Ptr INSIDE package Figures.  In my non-working
code I had defined Circle_Ptr INSIDE my procedure
Test_Figures.  Apparently GNAT was getting confused 
when trying to resolve the accessibility levels between the
"locally" scoped Circle_Ptr definition and the "package"
scoped Figure_Ptr definition, or else what I did was just
plain wrong.

In short, I moved the line:

type Circle_Ptr is access all Circle;

from inside procedure Test_Figures to inside package
Figures... and everything works fine now.  I can
create Circle's and use Figure_Ptr or Circle_Ptr to
"point" to them, then I can convert back-n-forth
between Figure_Ptr and Circle_Ptr as desired.

Much nice... and works as I'd expect for my OO
dispatching purposes.

Thanks very much for testing this and answering my
question.

Do you think this is a bug in GNAT that I should report,
or was it in fact detecting the error properly?

Thanks again, Troy

Jon S Anthony <jsa@alexandria.organon.com> wrote in article
<JSA.97Aug16191349@alexandria.organon.com>...
> In article <33F4D31F.6E511B93@mci.com> Troy Noble <Troy.Noble@mci.com>
writes:
> 
> >   A_Figure := Figures.Figure_Ptr(C2_Ptr);
> >   -- previous line: operand has deeper accessibility level than target
> 
> This does not look correct.  Neither the access types nor the object
> decls have different access levels.  The following works fine under
> both gnat305 and gnat309 (both sparc.solaris)
> 
> with Figures;  use Figures;
> procedure Fig_Test is
>     C2_Ptr  : Circle_Ptr;
>     A_Figure: Figures.Figure_Ptr;
> begin
>     A_Figure := new Figures.Circle;        -- line (1)
>     C2_Ptr := Circle_Ptr(A_Figure);        -- line (2)
>     C2_Ptr := new Figures.Circle;
>     A_Figure := Figure_Ptr(C2_Ptr);
> end;
> 
> 
> What compiler are you using?
> 
> /Jon
> -- 
> Jon Anthony
> OMI, Belmont, MA 02178, 617.484.3383 
> "Nightmares - Ha!  The way my life's been going lately,
>  Who'd notice?"  -- Londo Mollari
> 




  reply	other threads:[~1997-08-18  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-15  0:00 Ada tagged types not as powerful as C++ for dispatching??? Troy Noble
1997-08-16  0:00 ` Jon S Anthony
1997-08-18  0:00   ` Troy Noble [this message]
1997-08-18  0:00     ` Robert A Duff
replies disabled

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