comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@home.com>
Subject: Re: (elementary question) Test on type ? Pragma inline(granularity)?
Date: Thu, 06 Sep 2001 17:10:31 GMT
Date: 2001-09-06T17:10:31+00:00	[thread overview]
Message-ID: <3B97AE06.B1C64D14@home.com> (raw)
In-Reply-To: 9n7gg7$bke$1@snipp.uninett.no

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



      reply	other threads:[~2001-09-06 17:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-04  8:41 (elementary question) Test on type ? Reinert Korsnes
2001-09-04  9:18 ` David C. Hoos, Sr.
2001-09-04  9:29   ` Reinert Korsnes
2001-09-04 11:02     ` Jacob Sparre Andersen
2001-09-04 11:05       ` Reinert Korsnes
2001-09-04 11:39         ` John McCabe
2001-09-04 13:30         ` Marin David Condic
2001-09-04 14:07           ` Ted Dennison
2001-09-04 14:48             ` Marin David Condic
2001-09-04 18:35               ` Mark Biggar
2001-09-04 19:33                 ` Marin David Condic
2001-09-04 14:15         ` Ted Dennison
2001-09-05  9:14           ` John McCabe
2001-09-05 14:19             ` Ted Dennison
2001-09-05 16:24               ` John McCabe
2001-09-05 18:33               ` Ehud Lamm
2001-09-06  9:36           ` Reinert Korsnes
2001-09-06 17:10             ` Warren W. Gay VE3WWG [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox