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,b2436a05996a83c8,start X-Google-Attributes: gid103376,public From: Mike Bates Subject: Constructing a modular type based on the size of an arbitrary type Date: 1999/09/14 Message-ID: <37DE8C45.A40AFE78@ssd.fsi.com>#1/1 X-Deja-AN: 525065419 Content-Transfer-Encoding: 7bit Organization: ioNET Inc. X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-09-14T00:00:00+00:00 List-Id: I am writing a generic package in which I need to be able to construct a modular type with the same size in bits as an arbitrary packed type passed in as a generic parameter. (This is to be able to do unchecked conversions between the arbitrary type and modular types; so they need to be the same size.) This is what I tried: generic type Arbitrary_Type is private; package Foo is type Modular_Type is mod Arbitrary_Type'Size ** 2; end Foo; The definition of Modular_Type fails because the value Arbitrary_Type'Size ** 2 is not static. (This surprises me, because the value is determinable at compile time.) I also tried the following, relying on the instantiator to pass in the value of Arbitrary_Type'Size ** 2: generic Arbitrary_Modulus : Natural; package Foo is type Modular_Type is mod Arbitrary_Type; end Foo; This also fails, again because the modulus expression is not static, even though it seems that it should determinable at compile time. It fails even if I use a numeric literal as the actual parameter in the instantiation. Is there any way to construct a modular type to match the size of an arbitrary type? Or is this as impossible as trisecting the angle? Mike Bates FlightSafety Simulation mikeb@ssd.fsi.com