comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Rules for Representation of Subtypes
Date: 1996/10/03
Date: 1996-10-03T00:00:00+00:00	[thread overview]
Message-ID: <DyoDuJ.4IF@world.std.com> (raw)
In-Reply-To: mazzanti-0210961730430001@131.114.200.115


In article <mazzanti-0210961730430001@131.114.200.115>,
Franco Mazzanti <mazzanti@iei.pi.cnr.it> wrote:
>Then the following should work too ...

Well, almost...

>generic
>   type Source(<>) is limited private;
>   type Target is (<>);
>function Checked_Scalar_Conversion (S:Source) return Target; 
>
>
>with Unchecked_Conversion;
>function Checked_Scalar_Conversion (S : Source) return Target is
>   type My_Rec is record
>      Scalar : Target;

That's illegal, since Target has unknown discrims.  But other than that,
this approach will work.

But, you don't really need to go to all that trouble.  If you just make
sure your integer types match the hardware (like -2**31..2**31-1 or
whatever), then unchecked conv of integers will tend to work just fine.

>At least, when I tried this with gnat it seemed to work.

Careful.  Erroneous means anything might happen, and "it works fine" is
one possible outcome.  But just because if works fine on GNAT doesn't
mean it will work fine on other compilers, or other versions of GNAT
(assuming it really is erroneous).

- Bob




  reply	other threads:[~1996-10-03  0:00 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-02  0:00 Rules for Representation of Subtypes Franco Mazzanti
1996-10-03  0:00 ` Robert A Duff [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-10-10  0:00 W. Wesley Groleau (Wes)
1996-10-10  0:00 ` Robert Dewar
1996-10-11  0:00 ` Ken Garlington
1996-10-03  0:00 Franco Mazzanti
1996-10-03  0:00 ` Robert A Duff
1996-09-28  0:00 Robert Dewar
1996-09-29  0:00 ` Robert A Duff
1996-09-29  0:00   ` Matthew Heaney
1996-09-28  0:00 Robert Dewar
1996-09-29  0:00 ` Robert A Duff
1996-09-29  0:00   ` Robert Dewar
1996-09-30  0:00     ` Art Schwarz
1996-09-30  0:00       ` Robert A Duff
1996-10-01  0:00       ` Larry Kilgallen
1996-10-01  0:00         ` Robert A Duff
1996-10-01  0:00         ` Brian R. Hanson
1996-09-29  0:00   ` Matthew Heaney
1996-09-28  0:00 Robert Dewar
1996-09-30  0:00 ` Keith Thompson
1996-09-22  0:00 Matthew Heaney
1996-09-23  0:00 ` Robert A Duff
1996-09-24  0:00   ` Matthew Heaney
1996-09-26  0:00     ` Robert A Duff
1996-09-26  0:00       ` Larry Kilgallen
1996-09-27  0:00         ` Robert A Duff
1996-09-27  0:00           ` Mark A Biggar
1996-09-30  0:00             ` Robert A Duff
1996-10-01  0:00               ` Larry Kilgallen
1996-10-01  0:00                 ` Robert A Duff
1996-10-01  0:00                 ` Samuel Tardieu
1996-10-01  0:00                   ` Ken Garlington
1996-09-28  0:00           ` Larry Kilgallen
1996-09-29  0:00             ` Robert A Duff
1996-09-29  0:00               ` Matthew Heaney
1996-09-30  0:00                 ` Robert A Duff
1996-09-30  0:00                 ` Robert Dewar
1996-09-30  0:00                   ` Matthew Heaney
1996-09-29  0:00               ` Larry Kilgallen
1996-09-29  0:00                 ` Matthew Heaney
1996-09-30  0:00                 ` Robert A Duff
1996-10-01  0:00                   ` Ken Garlington
1996-10-02  0:00                     ` Robert A Duff
1996-10-02  0:00                       ` Ken Garlington
1996-10-06  0:00                   ` Robert Dewar
1996-10-03  0:00             ` Robert Dewar
1996-09-27  0:00       ` Matthew Heaney
1996-09-27  0:00         ` Robert A Duff
1996-09-23  0:00 ` David C. Hoos, Sr.
1996-09-23  0:00   ` Robert A Duff
1996-09-23  0:00   ` Samuel T. Harris
1996-09-26  0:00     ` David C. Hoos, Sr.
1996-09-24  0:00   ` Robert Dewar
1996-09-26  0:00     ` Keith Thompson
1996-09-26  0:00       ` Matthew Heaney
1996-09-27  0:00         ` Robert Dewar
1996-09-27  0:00         ` Robert A Duff
1996-09-27  0:00           ` Robert Dewar
1996-09-27  0:00       ` Robert A Duff
1996-09-24  0:00   ` Robert Dewar
replies disabled

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