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-Thread: 103376,73cb216d191f0fef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.69.3.161 with SMTP id bx1mr67195pbd.1.1363214077257; Wed, 13 Mar 2013 15:34:37 -0700 (PDT) Path: jm3ni48626pbb.0!nntp.google.com!news.glorb.com!news-out.readnews.com!transit3.readnews.com!panix!newsfeed-00.mathworks.com!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Wed, 13 Mar 2013 18:34:35 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <8klywqh2pf$.1f949flc1xeia.dlg@40tude.net> <513f6e2f$0$6572$9b4e6d93@newsspool3.arcor-online.net> <513faaf7$0$6626$9b4e6d93@newsspool2.arcor-online.net> <51408e81$0$6577$9b4e6d93@newsspool3.arcor-online.net> <1xqmd3386hvns.1og1uql2cgnuf$.dlg@40tude.net> <5140b812$0$6575$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1363214076 11161 192.74.137.71 (13 Mar 2013 22:34:36 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 13 Mar 2013 22:34:36 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:oCC3BDT3V9Fk32EXrZudKEeS9po= Content-Type: text/plain; charset=us-ascii Date: 2013-03-13T18:34:35-04:00 List-Id: "Dmitry A. Kazakov" writes: > Ada's design choice was in favor of Integer's order: 'Succ (3)=4. But > user's expectation was the order from the problem space 'Succ(3)=5. As a user, what is your expectation for the following? X : Prime := 3; A : Integer := Prime'Succ (X); -- A = 4 B : Integer := Integer'Succ (X); -- B = 4 C : Integer := X + 1; -- C = 4 D : Prime := X + 1; -- Constraint_Error on the ":=", not on the "+" E : Integer := Positive'Pred(1); -- E = 0 F : Integer := Positive'Pred(-100); -- F = -101 type T is range 1..10; G : T := 10; H : T := 10; I : T := (G + H) / 2; -- I = 10 I've shown the actual Ada semantics in comments. Does your expectation differ? (Nitpick: The expression G+H could overflow, if the compiler chose a base range for T of -10..10. No compiler does that, but if you're worried about it, you could declare "type T is new Integer range 1..10" instead.) - Bob