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: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: type conversion Date: Mon, 13 Oct 2014 08:26:48 +0100 Organization: A noiseless patient Spider Message-ID: References: <8d412a6d-5589-4601-a7f8-5bb6d1b8850f@googlegroups.com> <1413106638.3344.5.camel@obry.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="865ecc8333c04b7dc8d5f87fc772110b"; logging-data="27561"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XE5K4KK3PYvzT3aWEme0ibwt19AgpfP0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:pbi1kZlqXb/nc+ybZUVzotoakGc= sha1:MAxViDy0y0tU2/0g8eogvJHI+j8= Xref: number.nntp.giganews.com comp.lang.ada:189717 Date: 2014-10-13T08:26:48+01:00 List-Id: Georg Bauhaus writes: > On 12.10.14 11:37, Pascal Obry wrote: >> To control the message or the exception to be raised one can use the >> Predicate_Failure aspect: >> >> subtype Integer_String is new String >> with Dynamic_Predicate => Integer'Value (Integer_String) in Integer, >> Predicate_Failure => "not an integer string"; > > Is Predicate_Failure a new aspect in GNAT? My RM does not list it, > and GNAT GPL 2014 rejects it. GNAT does, however, accept > > subtype Integer_String is String > with Dynamic_Predicate => Integer'Value (Integer_String) in Integer > or else raise Assertion_Error with "not an integer string"; > > (And warns that one should use 'Valid instead of a membership test, > even though there is no object to which one could apply 'Valid.) Unfortunately using 'Valid would make no difference, because if Integer_String is say "foo" you get Exception name: CONSTRAINT_ERROR Message: bad input for 'Value: "foo"