comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: which compiler is right?
Date: Wed, 17 Mar 2004 22:57:42 -0600
Date: 2004-03-17T22:57:42-06:00	[thread overview]
Message-ID: <105ib2sanngpi0f@corp.supernews.com> (raw)
In-Reply-To: mailman.104.1079549636.327.comp.lang.ada@ada-france.org

<Lionel.DRAGHI@fr.thalesgroup.com> wrote in message
news:mailman.104.1079549636.327.comp.lang.ada@ada-france.org...
...
> For the record, here is how I use those packages:
> I provide the concrete realization of Priority by renaming
> the one in the generic instantiation.
>
> with Pkg1;
> package Pkg3 is
>    type T_Event is new Pkg1.T_Event with null record;
>    function Priority (Event : in T_Event) return Natural;
> end Pkg3;
>
>
> with Pkg2;
> package body Pkg3 is
>    package Pkg2_Instanciation is new Pkg2 (T_Event);
>    function Priority (Event : in T_Event) return Natural
>       renames Pkg2_Instanciation.Priority;
> end Pkg3;

You don't need to have the same name of routine for this purpose, and it
probably would less confusing (both to language lawyers and to readers of
your code) if the name was different in the generic.

That is, if the generic looked like:

generic
    type T_Event (<>) is new Pkg1.T_Event with private;

package Pkg2 is
    function Priority_Implementation (Event : in T_Event) return Natural;
end Pkg2;

with Pkg2;
package body Pkg3 is
   package Pkg2_Instanciation is new Pkg2 (T_Event);
   function Priority (Event : in T_Event) return Natural
      renames Pkg2_Instanciation.Priority_Implementation;
end Pkg3;

gives you exactly what you want, without running into obscure language bugs.

               Randy.






  reply	other threads:[~2004-03-18  4:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-17 18:53 which compiler is right? Lionel.DRAGHI
2004-03-18  4:57 ` Randy Brukardt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-03-17 18:56 Lionel.DRAGHI
2004-03-17 10:16 Lionel.DRAGHI
2004-03-17 17:48 ` Randy Brukardt
2004-03-16 15:35 Lionel.DRAGHI
2004-03-16 13:44 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
2004-03-19 19:48       ` Randy Brukardt
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