Re: which compiler is right?

From: Adam Beneschan (adam_at_irvine.com)
Date: 03/18/04


Date: 18 Mar 2004 12:33:04 -0800


"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



Relevant Pages

  • Re: UserForm Data Validation. I tried and tried but cant figure it out.
    ... >> routine which contains the declaration, there is tremendous scope for ... >> confusion since the default instance will still work from any other ... > of the default one there is, effectively, a hidden declaration. ...
    (microsoft.public.word.vba.general)
  • Re: which compiler is right?
    ... > neither a primitive subprogram nor is overriding. ... primitives. ... like an overriding routine, but it is not. ... confusion if that was actually intended. ...
    (comp.lang.ada)
  • Re: Intermittent Error 12 - Variable Not Found
    ... routine in which they are defined. ... Variable declared PRIVATE work more like what you described. ... A private variable's scope is that of the ... overridden by another declaration further down the call tree. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Reported any bugs in C-LAPACK routine DSPEVX?
    ... >>and call the latest Fortran LAPACK routines directly. ... For the dstevx routine I do it like this. ... the declaration can be done also in a header.h file which is ... There exists other ways of including lapack routines into C. ...
    (sci.math.num-analysis)
  • This is what I want done, but I dont want to do it
    ... I could descend from an existing class by typing in the declaration + ... overriding any abstract methods etc, but that would take a long time. ... works on the fact that base classes + methods already exist). ... I spend too much time writing code, I want to be more idle :-) Any other ...
    (borland.public.delphi.non-technical)