From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_05,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!bellcore!ulysses!allegra!princeton!siemens!gypsy!rosen From: rosen@gypsy.UUCP Newsgroups: comp.lang.ada Subject: Derived Subprogram Weirdness Message-ID: <38000036@gypsy.UUCP> Date: Fri, 14-Nov-86 13:22:00 EST Article-I.D.: gypsy.38000036 Posted: Fri Nov 14 13:22:00 1986 Date-Received: Mon, 17-Nov-86 08:55:52 EST Nf-ID: #N:gypsy:38000036:000:2856 Nf-From: gypsy!rosen Nov 14 13:22:00 1986 List-Id: 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| --------/