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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7be3870dd9c9518f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-14 17:44:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.litech.org!news-xfer.cox.net!cox.net!nntp2.aus1.giganews.com!nntp.giganews.com!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!beastie.ix.netcom.com!nobody From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: CONSTRAINT_ERROR - why? Date: Sat, 14 Dec 2002 16:49:36 -0800 Organization: >> Leaf-Eating Penguins? << Message-ID: <1jjgta.os3.ln@beastie.ix.netcom.com> References: <3DFB7841.F898C02@t-online.de> <3DFB9276.7070809@acm.org> <3DFBB00B.230289A2@t-online.de> NNTP-Posting-Host: a5.f7.cf.d1 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Server-Date: 15 Dec 2002 01:05:40 GMT User-Agent: KNode/0.6.1 X-noarchive: yes Xref: archiver1.google.com comp.lang.ada:31836 Date: 2002-12-15T01:05:40+00:00 List-Id: Alfred Hilscher fed this fish to the penguins on Saturday 14 December 2002 02:26 pm: > > Is there no way to avoid this extra assignment? I expected something > like function "/" (Left, Right : universal_integer) return Byte; > The philosophy of Ada is to assume nothing. IE, no hidden type coercions (unlike C, FORTRAN, etc.). with Interfaces.C; use Interfaces.C; with Text_IO; use Text_IO; procedure Test is type BYTE is new Interfaces.C.Unsigned_Char; type Fac_Conf_Struct is record Struct_Length : BYTE; Filler : String (1..32); end record; X : Fac_Conf_Struct; begin Put_Line ("Struct_Length=" & Integer'Image (Fac_Conf_Struct'Size / 8)); X.Struct_Length := 33; X.Struct_Length := (BYTE(Fac_Conf_Struct'Size / 8)); -- Value is 33, too. end Test; Note the EXPLICIT type specification! It could still cause an error should the result of the divide exceed the value "BYTE" can contain. -- > ============================================================== < > wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed@dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ <