From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,45a9122ddf5fcf5 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Rules for Representation of Subtypes Date: 1996/10/03 Message-ID: #1/1 X-Deja-AN: 186823335 references: organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-10-03T00:00:00+00:00 List-Id: In article , Franco Mazzanti 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