[comp.lang.ada] Derived Subprogram Weirdness

rosen@gypsy.UUCP (11/14/86)

Anybody care to venture a guess as to what's going on in the following
program.  I stumbled across the problem by accident and am not sure if I am
doing something legal or not.  Any responses are greatly welcomed.

I am implicitly deriving a subprogram from a particular package by creating
a derived type based on a type which this package exports.  It turns out
that I have provided a specification for a subprogram which exactly matches
(it has the same subprogram profile) as one that I am deriving implicitly.

My questions are:

	1) Is this legal?  I have two subprograms declared (one implicit,
	   the other explicit) which have the same profile at the same
	   lexical level so therefore this should not be allowed, but the
           compiler has no complaint.

	2) If it is legal, what are the semantics of referencing one over
	   the other?  Am I doing overloading?  Am I hiding one from the
	   other?  Have I cancelled one out (whatever that means in Ada)?
	   Or something else?

I gave different results from 2 different compilers, so something is not
right.  I just can't quite figure out what is going on.  Things get weirder
when you try and write the body for the explicit procedure which calls the
implicit procedure.

Here is the program:

----------------------------------------------------------------------------

package FOO is

  type BLOTZ is limited private;

  procedure DOIT (X: in BLOTZ);

private

  type BLOTZ is range 1..10;

end FOO;

----------------------------------------------------------------------------

with FOO;
package BAR is

  type YUCKO is limited private;

  procedure DOIT (Y: in YUCKO); -- My explicit version of DOIT

private

  type YUCKO is new FOO.BLOTZ; -- I get an implicit DOIT for YUCKO from FOO

end BAR;

----------------------------------------------------------------------------

package body BAR is

  A: YUCKO;

  procedure DOIT (Y: in YUCKO) is
  begin
    null;
  end DOIT;
  
begin
  BAR.DOIT(X => A);	-- OK to compiler

  DOIT(Y => A);		-- OK to compler
  BAR.DOIT(Y => A);	-- Compiler dislikes, but why not?

  DOIT(A);
		 -- Hey, which DOIT am I using, the explicit one or the
		 -- implicit one?  They both are declared in the same
  		 -- scope and there is no way to disambiguate them, plus
		 -- the compiler didn't complain.  I am not hiding an outer
  		 -- one from and inner one.  I appear to be doing overloading,
		 -- but not really.
end BAR;

----------------------------------------------------------------------------
--------------------
| Steve Rosen
| Siemens Research and Technology Laboratories 
| Princeton, NJ

 --------				    ------------
| USENET |			           |  INTERNET  |
 --------			            ------------

--------\			rosen%gypsy%siemens@TOPAZ.RUTGERS.EDU
princeton|
    ihnp4|
  allegra|====>!siemens!gypsy!rosen
 columbia|
   vrdxhq|
--------/