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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ce805592e46d231 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-06 10:17:35 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!nnrp1.tor.metronet.ca!not-for-mail Message-ID: <3B97AE06.B1C64D14@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: (elementary question) Test on type ? Pragma inline(granularity)? References: <9n24g4$17q$1@snipp.uninett.no> <9n279a$1ua$1@snipp.uninett.no> <3B94B4B4.CE1955D6@nbi.dk> <9n2ctk$36v$1@snipp.uninett.no> <9n7gg7$bke$1@snipp.uninett.no> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 06 Sep 2001 17:10:31 GMT NNTP-Posting-Host: 198.96.47.195 NNTP-Posting-Date: Thu, 06 Sep 2001 11:10:31 MDT Organization: MetroNet Communications Group Inc. Xref: archiver1.google.com comp.lang.ada:12818 Date: 2001-09-06T17:10:31+00:00 List-Id: Reinert Korsnes wrote: > Ted Dennison wrote: ... > generic > type T is (<>); > with function F(X : T) return Float; > procedure P(A : some type; B : another type; X : T); > > function F(X: some anumeration type) returns Float; > function F(X: another enumeration type) returns Float; > > and: > > procedure P1 is new P(T => simething,F); Actually, you can take this one step further: generic type T is (<>); with function F(X : T) return Float is <>; -- note the "is <>" procedure P(A : some type; B : another type; X : T); With the "is <>" added, the compiler can find the correct procedure/function without the explicit argument supplied: procedure P1 is new P(T => simething); Note that if you have a protected type involved within the generic, with different entrys by type, then you'll have an additional problem to solve. For example: protected type Protected_Buffer_Type is entry Put(Items : U8_Array; Last : out Natural); entry Put(Items : I8_Array; Last : out Natural); entry Put(Items : I16_Array; Last : out Natural); entry Put(Items : I32_Array; Last : out Natural); entry Get(Items : out U8_Array; Last : out Positive); ... private ... end Protected_Buffer_Type; Using wrapper procedures for each of the Put entries helps however: procedure Put(Buffer : in out Protected_Buffer_Type; Items : U8_Array); procedure Put(Buffer : in out Protected_Buffer_Type; Items : I8_Array); procedure Put(Buffer : in out Protected_Buffer_Type; Items : I16_Array); procedure Put(Buffer : in out Protected_Buffer_Type; Items : I32_Array); With the use of the "with procedure ... is <>" trick, I was able to work around the problem (I'd be interested in a more direct solution if there was one, BTW). After a pragma inline(), the effect is the same as calling the Put() entry directly from within the generic code. But... How do I explicitly "pragma inline(Put)" for specific procedures? I do not want to inline all Put() calls; certainly not the Ada.Text_IO.Put() calls. Hmmm... does this mean the best granularity is at: pragma inline(package.etc.Put) the package level? Maybe I need more RTFM. [if there were prior copies of this post that got out, my apologies.. I am struggling with Netscape 6.1 (grrr), this post was finally submitted after 5 failures in 6.1, by the older venerable NS 4.7] -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg