comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: (elementary question) Test on type ?
Date: Tue, 04 Sep 2001 14:07:13 GMT
Date: 2001-09-04T14:07:13+00:00	[thread overview]
Message-ID: <le5l7.3173$4z.4905@www.newsranger.com> (raw)
In-Reply-To: 9n2l16$bqv$1@nh.pace.co.uk

In article <9n2l16$bqv$1@nh.pace.co.uk>, Marin David Condic says...
>
>What you are trying to do is basically impossible in Ada. You can't have a
>generic parameter that is, say, "private" and then try to test to see if the
>actual is of type Integer or Float. There are a couple of reasons for this:

Actually it is doable, if the type in question is a tagged type. In that case
you can easily do something like:

if Object_A in Parent_Type_X'class then ....

The reason this won't work for Integer is that Integer isn't tagged. Thus:

1) You can't use 'Class on it (or a subtype of it).
2) You can't pass it into a routine that can also take other types for the same
parameter.

I suppose you would be able to do that with Integer if Ada had a type system
where every type was derived from some common root type. I think there are some
languages out there that work that way. Ada just isn't one of them.


---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  reply	other threads:[~2001-09-04 14:07 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
2001-09-04 13:30         ` Marin David Condic
2001-09-04 14:07           ` Ted Dennison [this message]
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