comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: generic type identification
Date: Sun, 05 Jan 2003 05:42:29 GMT
Date: 2003-01-05T05:42:29+00:00	[thread overview]
Message-ID: <9BPR9.448239$GR5.153733@rwcrnsc51.ops.asp.att.net> (raw)
In-Reply-To: HANR9.4571$LY2.262084@newsc.telia.net

> I wish it was this simple but as you will probably pass OpenGL alot of
> vertices every frame (if there are lots of stuff changing in the scene) you
> don't want to pass it 64bit doubles if 32bit floats are enough. Same goes
> for int vs short.
  So you surely don't want to spend execution time figuring out what
"type" was passed in.
  If I understand correctly, you have a set of C procedures like
    something_int(int x);
    something_short(short x);
    something_float(float x);
    something_double(double x);
etc. and you want to get the compiler to figure out which one to call?
How about
  package Short_Forms is
    subtype Distances is Interfaces.C.Short;
    procedure Something(x : in Distances);
    procedure Other_Thing(x : in Distances);
  end Short_Forms;
  package Int_Forms is
    subtype Distances is Interfaces.C.Int;
    procedure Something(x : in Distances);
    procedure Other_Thing(x : in Distances);
  end Int_Forms;
  package Float_Forms is
    subtype Distances is Interfaces.C.C_Float;
    procedure Something(x : in Distances);
    procedure Other_Thing(x : in Distances);
  end Float_Forms;
and then 'with' and 'use' the appropriate one in each calculation package?
  with Int_Forms; use Int_Forms;
  package body Draw_Stuff is
    x,y : Distances;
    ...
    Something(x);
Does that match what you are trying to do?



  reply	other threads:[~2003-01-05  5:42 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
2003-01-05  3:25       ` David Holm
2003-01-05  5:42         ` tmoran [this message]
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