comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com (Adam Beneschan)
Subject: Re: which compiler is right?
Date: 18 Mar 2004 12:33:04 -0800
Date: 2004-03-18T12:33:04-08:00	[thread overview]
Message-ID: <b4682ab7.0403181233.68d63fb5@posting.google.com> (raw)
In-Reply-To: 105iblbigdett75@corp.supernews.com

"Randy Brukardt" <randy@rrsoftware.com> wrote in message news:<105iblbigdett75@corp.supernews.com>...
> "Adam Beneschan" <adam@irvine.com> wrote in message
> news:b4682ab7.0403170927.cc800a5@posting.google.com...
> ...
> > Since the score is currently 2-0 that the code should be illegal,
> > maybe I should point out that not everyone agrees with this analysis,
> > before you decide it's necessary to fix your code.  My belief is that
> > since the Priority routine declared in Pkg2 is declared in a different
> > scope than whatever type will be used to instantiate Pkg2, Priority is
> > neither a primitive subprogram nor is overriding.  I think GNAT is
> > correct to accept the code.
> 
> I thought that too, but that's not what the language says. Routines can be
> overriding if they are inherited, anywhere.

I'm not sure how this is pertinent, since the routine causing the
error is not inherited.


> That's so that a type declared
> in a body can have overriding routines, even though it can't have
> primitives. Scopes have absolutely nothing to do with overriding (look at
> 8.3 again if you don't believe me).

Sorry, I looked at it and I still don't believe you.  8.3(9) says that
a declaration can override another homograph if the declaration
"occurs immediately within the same declarative region", etc.  The
term "immediately within a declarative region" is defined by 8.1(13)
and most definitely has to do with scopes.  If you declare a routine
in a nested inner package, it cannot override a routine declared
(implicitly or explicitly) in an outer package, because the routine in
the inner package is not *immediately* declared in the same
declarative region as the routine declared in the outer package.

If you are aware of this and still maintain that scopes have nothing
to do with overriding, then I'm afraid I'm not following you.


> Similarly, primitiveness has nothing to
> do with it.

Primitiveness has nothing to do with whether a routine is overriding;
but since the compiler in the original example reported an error
because it thought the declared routine was primtive, it's certainly
relevant to the problem.  Again, I'm probably just not understanding
you correctly.


> I think it should be illegal simply because it is very confusing. This looks
> like an overriding routine, but it is not.

Now I'm convinced that I'm lost.  I thought you were disagreeing with
me when I said the function (i.e. the Priority explicitly declared in
the generic) is not an overriding routine?


> And if it is not overriding,
> calls outside of the generic are almost certainly ambigious (for use clause
> users, anyway).

If you instantiate Pkg2 and then USE the instantiation, then calls to
Priority might be ambiguous (depending on whether the Priority
operation of the actual type is directly visible).

                                -- Adam



  reply	other threads:[~2004-03-18 20:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-16 13:44 which compiler is right? Lionel.DRAGHI
2004-03-16 14:56 ` Dmitry A. Kazakov
2004-03-16 23:43 ` Randy Brukardt
2004-03-17 17:27 ` Adam Beneschan
2004-03-18  5:07   ` Randy Brukardt
2004-03-18 20:33     ` Adam Beneschan [this message]
2004-03-19 19:48       ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2004-03-17 18:56 Lionel.DRAGHI
2004-03-17 18:53 Lionel.DRAGHI
2004-03-18  4:57 ` Randy Brukardt
2004-03-17 10:16 Lionel.DRAGHI
2004-03-17 17:48 ` Randy Brukardt
2004-03-16 15:35 Lionel.DRAGHI
1997-07-24  0:00 Which compiler is right ? Strategies
1997-07-25  0:00 ` Tucker Taft
1997-07-25  0:00 ` Albert K. Lee
replies disabled

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