comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: generic type identification
Date: Sat, 04 Jan 2003 19:27:21 GMT
Date: 2003-01-04T19:27:21+00:00	[thread overview]
Message-ID: <tAGR9.629018$NH2.43402@sccrnsc01> (raw)
In-Reply-To: _BAR9.4055$FF4.251139@newsb.telia.net

>For instance, glVertex has 24 different declarations depending on whether
>you use (C) floats, doubles, integers, shorts etc and whether your send it
  So you don't really need to know the "type" in the Ada sense of the
word, just in the C sense.  If it's OK to call the "double" version for
any float, and the "int" version for shorts as well as ints, then one
generic for int and one for double should do the job.  So how about:

generic
  type An_Integer_Type is range <>;
  type A_Float_Type is digits <>;
package Example
  procedure Some_Procedure(Item: in An_Integer_Type);
  procedure Some_Procedure(Item: in A_Float_Type);
end Example;

package body Example is

  procedure Some_Procedure(Item: in An_Integer_Type) is
  begin gl_i_SomeProcedure(Interfaces.C.Int(Item));end Some_Procedure;

  procedure Some_Procedure(Item: in A_Float_Type) is
  begin gl_d_SomeProcedure(Interfaces.C.Double(Item));end Some_Procedure;

end Example;



  parent reply	other threads:[~2003-01-04 19:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-04  1:50 generic type identification David Holm
2003-01-04  2:04 ` chris.danx
2003-01-04  5:39 ` tmoran
2003-01-04 12:39   ` David Holm
2003-01-04 16:13     ` James S. Rogers
2003-01-05  3:28       ` David Holm
2003-01-05 10:03         ` Gautier
2003-01-04 19:27     ` tmoran [this message]
2003-01-05  3:25       ` David Holm
2003-01-05  5:42         ` tmoran
2003-01-06 17:56     ` Stephen Leake
replies disabled

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