comp.lang.ada
 help / color / mirror / Atom feed
From: john.mccabe@emrad.com.nospam (John McCabe)
Subject: Re: (elementary question) Test on type ?
Date: Tue, 04 Sep 2001 11:39:22 GMT
Date: 2001-09-04T11:39:22+00:00	[thread overview]
Message-ID: <3b94bb3e.13397965@news.demon.co.uk> (raw)
In-Reply-To: 9n2ctk$36v$1@snipp.uninett.no

On Tue, 4 Sep 2001 13:05:21 +0200, Reinert Korsnes
<Reinert.Korsnes@ffi.no> wrote:

>> Seriously, what are you trying to do?
>
>Just do a bit different things in the function depending on the type
>of X.   Say, X is Float of Interger....

Generics are the place to do identical stuff independent of the types.
If you want to do different stuff depending on the type, then you
should use overloaded function. I'm not sure whether this is possible
(and I can't check at the moment as I don't use Ada any more), but you
may be able to pass overloaded functions as generic actual parameters
and then just make a call where the compiler will handle the types.

e.g.

generic
   type MyType is (<>);
   with procedure Test (InParm : in Integer);
   with procedure Test (InParm : in SomeOtherDiscreteType);
package X
   :

Then call Test when you want. I guess what you could do was define a
type somewhere e.g: type PossibleTypes is (Int, Flt, Enum); then use
declare the Test operations as functions that returned that type.

Hope this helps.



Best Regards
John McCabe



  reply	other threads:[~2001-09-04 11:39 UTC|newest]

Thread overview: 20+ 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 [this message]
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             ` (elementary question) Test on type ? Pragma inline(granularity)? Warren W. Gay VE3WWG
  -- strict thread matches above, loose matches on Subject: below --
2001-09-04 17:55 (elementary question) Test on type ? Beard, Frank
2001-09-05  9:16 ` John McCabe
replies disabled

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