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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.99.64.194 with SMTP id n185mr14185682pga.53.1480452310546; Tue, 29 Nov 2016 12:45:10 -0800 (PST) X-Received: by 10.157.11.248 with SMTP id 111mr1372512oth.4.1480452310481; Tue, 29 Nov 2016 12:45:10 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!p16no3101350qta.1!news-out.google.com!m27ni4811qtf.1!nntp.google.com!n6no3102575qtd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 29 Nov 2016 12:45:10 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=174.28.218.229; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 174.28.218.229 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada 2012 Constraints (WRT an Ada IR) From: Shark8 Injection-Date: Tue, 29 Nov 2016 20:45:10 +0000 Content-Type: text/plain; charset=UTF-8 X-Received-Bytes: 3142 X-Received-Body-CRC: 1017032124 Xref: news.eternal-september.org comp.lang.ada:32517 Date: 2016-11-29T12:45:10-08:00 List-Id: On Tuesday, November 29, 2016 at 10:53:59 AM UTC-7, Niklas Holsti wrote: > 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. It is. > > Subtype P1 is Integer range 1..Integer'Last; > > And this is the standard definition of Positive. It is. > > 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. But insofar as a "type" (the collection of values and operations*) goes it is the same: its values have the same range, the operations* are the same, and it raises the same error when they are violated. * Assuming we're considering attributes as something different than an 'operation' and excluding them. > > > Subtype P3 is Integer with > > Static_Predicate => P3 in 1..Integer'Last, > > Predicate_Failure => raise Constraint_Error; > > Same difference as for P2, I think. > So there *IS* something in common about all the above, that's what the thrust of the topic (an Ada IR) is getting at. Something like "can't use attributes like 'First" could be handled [implementation-wise] as something like: -- Vastly oversimplified. Type Subtype_Node( Accessible_Attributes : Boolean := True ) is record Name : String_Holder; Parent : Type_Node; Values : -- value-set. -- or however we represent the constraints, errors, and messages. enc; end record;