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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada 2012 Constraints (WRT an Ada IR) Date: Tue, 29 Nov 2016 19:53:56 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net fwFDFyFbU0/kv+SLJIg89gl9nS6ZJSSA0pLV1RJzgLx0TuMHSn Cancel-Lock: sha1:I6Yja1fPIolCUGBM0wYNVKiHNzU= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:32512 Date: 2016-11-29T19:53:56+02:00 List-Id: On 16-11-29 01:49 , Shark8 wrote: > So, with Ada 2012 we gained some really nice possibilities > with the way to express constraints, the downside is that > there's now a fairly wide range of ways to express constraints on > types. Obviously these differences must be accounted for, but > the are functionally equivalent, for example: > > Subtype P0 is Natural range Natural'Succ(Natural'First)..Natural'Last; This seems the same as Positive, to me. > Subtype P1 is Integer range 1..Integer'Last; And this is the standard definition of Positive. > Subtype P2 is Integer > with Static_Predicate => P2 in 1..Integer'Last > or else raise Constraint_Error; Perhaps it was obvious to you, but this differs from Positive in that you cannot write P2'First or similar (illegal by RM 3.2.4(26/3)), but you can write Positive'First. > Subtype P3 is Integer with > Static_Predicate => P3 in 1..Integer'Last, > Predicate_Failure => raise Constraint_Error; Same difference as for P2, I think. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .