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,c462e8ad74872a98 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Question on modular types Date: 1997/01/04 Message-ID: #1/1 X-Deja-AN: 207784140 references: <01bbfa96$66d516a0$8d2d5c8b@jerryware> organization: New York University newsgroups: comp.lang.ada Date: 1997-01-04T00:00:00+00:00 List-Id: Jerry said "Clearly, all values are invalid, and that without inporting any values from the outside world." No! If it is clear to you, you need your Ada prescription fixed :-) A := -1; -1 is not a literal here, it is an expression, and the unary minus operator is a modular unary minus. This is a useful, intended, and clearly documented facility. Note that if you did Minus1 : constant := -1; uint := minus1; then you would get the constraint error: 1. procedure b is 2. type x is mod 256; 3. k : constant := -1; 4. r : x; 5. 6. begin 7. r := -1; 8. r := k; | >>> value not in range of type "x" defined at line 2 >>> static expression raises "constraint_error" 9. end; That's because the minus operator in line 3 is the one that works on root integer (I would really prefer to say universal integer, but I think root integer is correct), and really does give minus one, and that is indeed out of range, as detected (statically in this particular case). Note that for modular types of sizes corresponding to hardware sizes (typically 8,16,32) there will of course be no invalid values ever.