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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: Pascal Obry Newsgroups: comp.lang.ada Subject: Re: type conversion Date: Sun, 12 Oct 2014 11:37:18 +0200 Organization: Home - http://www.obry.net Message-ID: <1413106638.3344.5.camel@obry.net> References: <8d412a6d-5589-4601-a7f8-5bb6d1b8850f@googlegroups.com> Reply-To: pascal@obry.net NNTP-Posting-Host: KpDErP2zF8NnM8mDMNH95w.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Complaints-To: abuse@aioe.org X-Mailer: Evolution 3.12.6-1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:22380 Date: 2014-10-12T11:37:18+02:00 List-Id: Le samedi 11 octobre 2014 =C3=A0 22:57 -0600, Shark8 a =C3=A9crit :=20 > Almost, >=20 > Subtype Integer_String is new String > with Dynamic_Predicate =3D> Integer'Value( Integer_String ) in Integer > or else raise Constraint_Error; I don't see the point of the "or else" part. The exception Assertion_Error will be raised if the first part "Interger'Value .. in Integer" is not True anyway. 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 =3D> Integer'Value (Integer_String) in Integer, Predicate_Failure =3D> "not an integer string"; or subtype Integer_String is new String with Dynamic_Predicate =3D> Integer'Value (Integer_String) in Integer, Predicate_Failure =3D>=20 raise Constraint_Error with "not an integer string"; --=20 Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://v2p.fr.eu.org http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B